Home > Software engineering >  Do browsers not follow the HTTP spec's Cache-Control correctly?
Do browsers not follow the HTTP spec's Cache-Control correctly?

Time:03-24

I am somewhat new to web development and have noticed an issue, Browsers seem to not respect the Cache-Control header, I have it set to no-cache, no-store, must-revalidate but yet many of my clients have a cache to begin with (which no-store should prevent according to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#no-store) and the cache is used rather than revalidating with the server leading to broken pages when I change a JS script referenced in a page, only after I tell them to refresh without cache does the browser then fetch the new file but for the browsers to be compliant with the HTTP protocol and spec, don't they need to respect the no-store policy or are none of the major browsers properly compliant with the HTTP protocol/spec and why haven't they been fixed so we don't need workaround solutions like query strings appended to files or using the file's hash or last modification date?

CodePudding user response:

You initially served the resource without cache headers. In that case, the specification allows the client to choose the cache time itself:

Since origin servers do not always provide explicit expiration times, a cache MAY assign a heuristic expiration time when an explicit time is not specified, employing algorithms that use other header field values (such as the Last-Modified time) to estimate a plausible expiration time.

Different browsers will use different algorithms, but in any case it probably won't be very long. Your problem might have already resolved itself.

As for adding query strings, I'm not sure exactly what technique you're referring to, but, no, it isn't a preferred technique for disabling caching.

  • Related