Skip to content

Will browsers cache the css, javascript and image files that RequestReduce serves?

mwrock edited this page Nov 6, 2011 · 3 revisions

As of this writing, all modern, non mobile browsers under their default settings will cache RequestReduce images, scripts and css. RequestReduce sets the following headers:

Cache-Control public This allows just about any cache including proxies and CDNs to cache the response. Not just your browser.
Expires A little under a year Tells caches that the response is not to be considered stale until the expires date. RequestReduce uses a far future expires date. The further in the future this date is, the less likely the browser wil send a request to the server. RequestReduce can afford to do this since the binary hash of the file contents is embedded in the file name itself. If the file content changes, so will the file name and the browser will go to the server and not use the previously cached file.
Etag 32 byte Hash of file content If the browser does send a request to see if its cache is invalid, it uses this value as a key to see if content has in fact changed. Since this value matches the hash of the file's contents, it will certainly be the same and RequestReduce will respond with a 304 to the browser sending no content and essentially confirming that the browser's cache is valid. In most browsers, invoking Refresh will cause the browser to go to the server and send the etag it had previously been sent in the If-None-Match request header. RequestReduce will check if this matches the hash of the file. The hash is in the url itse so it does not need to recompute a hash or even load the file from disk or sql. If it matches, it responds with a 304. A 304 is better than a 200 since it does not require the entire contents of the file to travel to the browser. Only the headers are sent.
Clone this wiki locally