I have some image resources that are immutable and can be cached forever. Chrome seems to respect my response headers, and does not re-validate the resources:
Here's an example of one of these resources in Chrome. As you can see, I include cache-control: public, max-age
, expires
, etag
and last-modified
and the resource is served from "memory cache":
Firefox, however, does not respect these headers and re-validates the resources on every load! My server is hit with a request for each profile pic every time the page loads, and returns a 304:
Here is an example of on such request that results in a 304:
I can't figure why Firefox ignores the cache headers and keeps going to the server for the 304. I've experimented with various cache-related headers and read the standard on what's "cacheable". I've ensured that caching is enabled in devtools. I've tried with devtools closed too, and I keep seeing the 304s in my server logs.
I've discovered that this only happens on a page refresh. A plain refresh, though, not shift- or shift-command-, but just a plain refresh. That's not the behavior I was expecting.