Tutorial :Is it true “JavaScript files are not reliably cached by browsers, CSS files are”


as mentioned on this site

Note that while JavaScript files are not reliably cached by browsers, CSS files are.



The browsers I know of "reliably cache" all kinds of static data (including JS and CSS, as well as images, HTML, etc) as long as they're served with proper cache-support headers. Maybe the text means something different than actual caching, such as parsing just once and then keeping some efficient internal format...? I don't know which browsers do or don't do that for different kinds of files, but at least under this hypothesis I can see why (e.g) CSS might be easier for the browser to keep in preprocessed form than JS.


I can't see any reason to make that claim expressly for JavaScript files. I can, however, see an argument made that caching can be unreliable in general regardless of the file type sent, depending on the server configuration, additional headers that are sent, proxies and caches, and how the end-user's browser is configured.


Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.

This is good if we want to actual cache the resource. If we want to force a new download set no-cache, which forces caches to submit the request to the origin server for validation before releasing a cached copy, every time. This is useful to assure that authentication is respected (in combination with public), or to maintain rigid freshness, without sacrificing all of the benefits of caching.

HTTP Server-Specified Expiration - specs

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »