To be able to serve the static content through providers that cache files to minimize bandwidth. All request needs to be unique to the file and change when the file changes.
An example of an easy way to do this is to add a garbage query parameter with garbage data, like the md5 checksum of the file. Or a timestamp of when the files where generated stored in the json file. Making the url unique for every file when it changes.
I have no knowledge with leaflet so I don't know if this is possible.
That sounds doable, but I would need to dig a bit more into it. Leaflet needs predictable URLs, but that does not prevent to have some prefix/suffix - i.e., using an ID unique per render instead of per file. That loses potential caching across renders, but I don't expect any caching across renders anyway.
The challenge though will be to keep pretty URLs for simple cases. In your use case - do you care about caching everything, or only large images/tiles? (do you have a specific provider you are targeting?)
Yeah, adding a ?v=<unix timestamp> to each jpg request and update that timestamp on new renders would work fine. This would allow me to tell the cache system to save stuff for e.g. 7 days and still be able to update to a new render and replace tile files, making it retrieve new tile files from the origin server during those 7 days.
I'm personally targeting cloudflare with their standard cache level. Cache everything. Many small files becomes a lot of bandwidth pretty fast with a couple of visitors.
Fwiw, I've moved the example to https://mapshot.palats.xyz , which uses Cloudflare+Backblaze (+my own server for html files) with extensive caching - and it seems to work quite decently.