01.08.08

Opera and Safari will cache content with a query string

Posted in Front End at 2:22 pm by admin

I was doing some checking up on our HTTP expiry headers that we were sending down dynamically with our product image caching script after it was reported by YSlow that they were not doing their job properly. Another concern I had is that I was under the impression that Opera and Safari do not cache content that has a query string.

Some browser cache mythbusting ensued.

A quick google search revealed only a few references to this phenomenon posted on out dated forum threads. After browsing our development version of our site with Opera 9 and Safari 3.1.2 and tailing the apache access log it was clear that this is not at all true. Given the correct expiry and cache control headers both Opera and Safari will cache content with a query string.

While a most of people completely ignore proper management of their users’ browser caches others make wild assumptions and generalisations about the behaviour of these strange beasts. They all behave slightly differently and the only way to know for sure if a particular browser is caching your content is to open your access log and check. One trick I have used in the past is to put sleep(5), or your language’s equivalent somewhere in the script execution, but this can get tiresome!

Hitting refresh in most browsers certainly all the ones I tried on my mac will re-request most if not all content regardless and also emptying your cache, clearing your private data or whatever does not always do as is promised. A quick tip to finish make sure your test browsing is clicking through links and not hitting refresh, or your tests wont be accurate.

Leave a Comment