Scott Farquhar

Back in July last year (how time flies), I investigated how we could use caching in our products to improve the user experience. This resulting in creating a framework for serving content that can be cached on the client. We now use this for JIRA, Confluence and Bamboo.

The idea is that some resources (css, images, javascript), never change between releases, and so we add 'caching headers' to say cache it forever. You can see how we have achieved that by using on the online services:

Test caching for Bamboo

However, when browsing certain sites like http://support.atlassian.com - these sites still felt very slow.

It turns out that SSL was the culprit! By default, firefox does not cache SSL content on disk, regardless of what the caching headers say. There is a property called browser.cache.disk_cache_ssl which by default if 'false'. Meaning that all content is cached in memory.

Turns out that Firefox also allows you to see what is in your browser's cache - type 'about:cache' into the location bar. With that property set, no https site will have anything in the memory cache.

Because the memory cache is so much smaller than the disk cache, the javascript and css etc will be pushed out much sooner than if it was on disk.

Turns out that Internet Explorer caches things to disk (correctly observing the caching headers), and there is an open bug for firefox: Change browser.cache.disk_cache_ssl default to true.

Note that if you do manually change the value to true, beware of this bug: mixed http/https warnings after enabling browser.cache.disk_cache_ssl.

Note that if you go through the proxy server, you probably won't see the slowness as much, as they will be cached by the proxy server.

Update: - this is now fixed in Firefox 3 if you set the Cache-control header to public. We will be updating all our applications shortly

7 Comment(s)

Hi, that's very nice stuff, but can you please tell me more about the header you modified to gain a better cache on the client?

* Cache-Control -> Has it to be private?
* Expires -> Has this set to the maximum? How great is the maximum?
* Last-Modified -> Do you use magic here?
* Anything else?

It would be great to know for my opensource library, thanks!

By Daniel at July 9, 2007 12:22 AM

Daniel,

Setting caching headers is a bit of a black art. I would recommend reading the RFC, and many many google searches to give you a background on the topic.

Cache-Control: If you don't want proxies to cache it, then set it private. It will depend on whether you are sending private information to the client (ie graphs / generated charts), or public information (eg css).

Expires: I do what Yahoo does, and set it to be 10 years in the future.

Last-Modified: I can't remember how I worked out what to do here. I recommend reading the RFCs.

Cheers,
Scott

By Scott Farquhar at July 13, 2007 8:25 PM

Thanks a lot,
I used the settings from the "caching test for Bamboo", and mixed in another header from yahoo now.
You can see the results when using my open source library for minifying, caching, gzipping and combining JavaScript and CSS called pack:tag (sf.net project site).

Greetings
Daniel

By Daniel at July 14, 2007 11:27 AM

Hello Scott, in your post you mention that "Turns out that Internet Explorer caches things to disk (correctly observing the caching headers)". This is the exact opposite of my own findings: IE does not cache anything over HTTPS. Do you have a correct set of headers (Expires, Cache-control: public, etc) that makes IE correctly cache, say, JavaScript or images over HTTPS? Thanks.

By Pardini at February 22, 2008 12:28 PM

Hello Scott, and Pardini
I have the same experience. HTTPS content is cached in IE but not in Firefox.
The cache header combination I have is working fine for HTTP, and both IE and Firefox disk cache is utilized, as expected. For HTTPS the same cache header combination gives in-memory caching in Firefox, but IE is not caching anything.
Does IE have the same concept of an in-memory cache for SSL. I really don't want disk caching of SSL content, but in-memory caching would be very useful.

By Groggy at August 28, 2008 6:45 AM

I wonder if IE is not caching for security reasons. e.g. not saving to a file since this could be sensitive information such as a credit card number.

By james at October 20, 2008 5:06 AM

I'm having a similar issue where graphics served through a secure SaaS app reload every time I open a new IE browser or tab. Once working inside the browser or tab, the graphics cache nicely, but there are 70+ images per page, so the first few pages or tough to sit through.

I see this in the Header:
meta http-equiv="cache-control" content="no-cache" /
meta http-equiv="pragma" content="no-cache" /

I'm sure the developers would like to keep some things from caching so they can make on-the-fly updates to js files etc, but is there a way to allow .jpg/.png images to be cached any way?

Please help!

By Sean Clouse at October 28, 2008 10:50 AM

Post a comment

If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.





Remember personal info?

Type the characters you see in the picture above.