I am doing something like this: if an image is cached on user’s computer and its timestamp is the same as the one on the server, then display the cached version; otherwise, do NOT load the image from the server.
I guess maybe JavaScript can do this, so I tagged this post as javascript. If it is improper, please help me to re-tag it.
Edit: Here I give more details about what I am going to implement. I am working on something like a web-based file explorer, where thumbnails are loaded only if the user click on a “view thumbnail” button beside each image. If a thumbnail is already cached, use the cached version; otherwise, show a generic image icon.
A browser can send the “If-Modified-Since” and “ETag” headers to indicate to the server that it does have a version of a resource. Check the W3 caching rules regarding these headers.
You could query for those headers on the server, sending back the generic icon if not found, and a “304 Not Modified” response if found.