A web app I'm developing uses lots of asynchronously loaded images that are often modified over time while their URLs are preserved. There are several problems with this:
If I do not provide the images with caching explicitly disabled in HTTP headers, the user will often receive an out of date image version, but doing so substantially increases server load.
How can I take the cache control away from the browser and manually evaluate if I should use the cached image or reload it from the server?Since there are many separate images to be loaded, I also parallelize image downloads over different hostnames (i.e. the
image01.example.com
,image02.example.com
, but all these hostnames resolve to the same physical server). Since theNN
of the hostname is generated randomly, I also get cache misses where I could have retrieved the up-to-date image from the browser cache. Should I abandon this practice and replace it with something else?What cache control techniques and further reading material would you recommend to use?