Monday, February 8, 2010

Firefox3 and Caching HTTPS content

We use HTTPS for our website because it caters to data for SMBs, I primarily use Firefox browser and it was not caching static content. I was ignorant because when I googled for caching HTTPS content I found various posts that told that content over HTTPS cant be cached. Surprising thing was that IE8 was caching the content and as I dont use IE much I didn't noticed it. Luckily I started used JAWR for DWR JS aggregation and recently I added ExtJS and prototype to it. Surprisingly after doing it the initial load became fast by 1-2 sec and I was surprised. Upon firing up Fiddler I was surprised to see that Firefox is not even making call for the aggregated JS. Ultimately I figured out that it was Cache-Control:Public header that was making all the difference. JAWR was setting Cache-Control: public, max-age=315360000, post-check=315360000, pre-check=315360000 and we were setting Cache-Control:Private, max-age=315360000. That's it done!! we changed the headers and now Initial load on second login is fast even after you close the browser.  When Cache-Control is private Firefox uses memory based caching and when Cache-Control is public Firefox uses disk based caching for HTTPS based content. You can type url about:cache to confirm this.

fyi this doesn't mean we don't need to focus on removing the no of http requests any more or looking for a CDN solution because according to a study by Yahoo surprisingly 40-60% requests are done from an empty cache. It just buys us some more time to automate some of the things like sprite creation and others in meanwhile.

No comments:

Post a Comment