This is something I just found out which definitely caught me off-guard but it makes sense. Basically in my Remix app since everything is pretty much static (not connected to any CMS and the content doesn't change that often), I've decided to put all the images inside the public folder and then reference those images as something like:
const imagesPerLocation = {
location1: ['/images/location-1-image-1.webp, '/images/location-1-image-2-webp'],
location2: ['/images/location-2-image-1.webp, '/images/location-2-image-2-webp']
}
Since I have a lot of images I decided against using static imports just because of the sheer number of imports that would cause and also because I'm not sure if I could use those static imports as I mentioned above. However what I've found by using this methodology is that every asset under the public folder gets this express.static("build/client/assets", { immutable: true, maxAge: "1y" }) meaning that those images will be forcefully be cached for a full year until the browser decides to use the provided ETag value. This effectively means that every image that I've changed thus far has not been completely reflected on the user's browsers.
What would be the recommended way in my scenario? Where static imports would quickly become way too cumbersome but at the same time I want to be able to change the images in the public folder freely and those would reflect on the user's browsers - either by hashing / fingerprinting or using less aggressive Cache-Control headers?