HTML5 AppCache – Cache-Control: no-store

AppCache,HTML5,JavaScript
03, November 2011

In my last post I talked about how fun is HTML5, and specifically on the Application Cache.

The cool to work with HTML5 is that everyting is new.
The downside of working with HTML5 is that everyting is new.

What i mean is that HTML5 is a new technology, and that many features are still in development.
In other words, is not fully defined as such features will work.
I think it’s a complicated issue for browsers, as they should implement these incomplete specifications.
But all this is part of the transition we’re in, and in some ways, this is very good.

Returning to AppCache, i will quote one of the problems i encountered using this feature, which i think has great potential.

As discussed before, the AppCache is not a feature that only allows your Web App to run offline.
The AppCache can reduce the “weight” of your app, reducing the number of requests.
Imagine that your Web App has 6 JavaScript files, 3 CSS files, and several images.
If any of these files doesn’t have constant updates, all of them can be “AppCached”.
Technically this means that if the amount of KB of your page is 200K, these 200K can be loaded directly Cache.
Yes, the browser has a default caching mechanism, but this cache is not controlled by the developer.
Another relevant factor is that none of the file header are considerd if your app is using AppCache.
With the exception of the Cache-Control: no-store.
Or not.

Well, in the specification are some details that i mentioned, but what i had a problem was this:
“Regardless of whether you include the address of the current page in the manifest, it will be cached”.
Remember that the AppCache was also thought to make an App run offline, it even makes sense, but creates other problems.
If my goal is to reduce the number of requests, and my page is constantly changing its content, this rule eliminates the possibility
to use the AppCache.
We have another rule in specification:
“With the exception of “no-store” directive, HTTP cache headers are overridden by manifests”.
Problem solved then?
No!
For some reason Google Chrome does not respect this rule.
To test this, change the settings of your server (in my case Apache):

 <FilesMatch "(.html)$">
 Head set Cache-Control "no-store"
 </ FilesMatch>

What i did was say that all HTML files should come with the Cache-Control “no-store”.
In Firefox and Opera this works fine. All files listed in the manifest to be AppCached are there, with the exception of the current page.
In Chrome, it just does not happen. The current page always comes from the cache.

Note that this problem can be solved if we use the default functionality of AppCache: Update manifest.
But this is not always possible, or i do not always want to do it.
Being dependent on a manifest file change to update the main content is a delicate thing.

Well, i’m still searching to see if this is a Chrome bug, or actually if Google ignored the rule of “no-store”.

Leave a Reply