I've seen a few conflicting answers across the net and I'm trying to understand this at a fundamental level. Say I have an image hotlinked (yes, with permission) on my site:
<img src="externalserver.com/catpic.png">
- Assuming all relevant parties have browser caching enabled, will this image be cached (aka are images from external sites even cacheable)?
- If the external server decides to serve a different image at the same file location, say with an .htaccess re-write, will the cache be broken?
- If the external server decides to serve the same image with a
?randomquerystringthereafter, will the cache be broken? - If the external server responds with an HTTP Status Code 204 instead of actually serving the image, what happens with caching?
Thanks! Happy holidays y'all.
It all depends.
Cache-ControlorExpiresheader. For more information look at Cache-Control header page at MDN.Cache-Controlheader,Expiresheader, whether resource is stale, whether server uses validator and whether it performs weak or strong validation. For more information look at HTTP conditional requests page at MDN.?randomquerystring. Rather, client may request resource with a?randomquerystring.?randomquerystringis called a cache buster. User agent will perform new request, but I heard that some proxies may ignore cache buster of that type and still return cached response.Cache-ControlandExpiresheaders. Relevant excerpt from RFC 2616:For more information about HTTP caching in general check HTTP Caching article by Ilya Grigorik.