Bad Offline State & Clearing Chrome Application Cache

Application cache is cool but it takes some work to get it right I’m finding. One little gotcha I just came across goes like this:

I made a change to someone else’s Javascript library and introduced a bug. I then rebuilt the project which regenerated the application cache manifest. I’ve got a local instance of Apache pointed at the output of my build so I go ahead and load the page to test the app cache event library modifications I just made. Whoops!

Seeing my new build and updated app cache manifest, Chrome downloads and caches the new (bad) bits, and seeing this, my old code reboots the page swapping in the newly updated app bits. Problem is the newly cached bits have a script error I introduced into an application cache event callback handler. F is for FAIL.

dunceLoading the app page fails due to the bug I introduced. The load (and fail) is 100% from the app cache.

Normally, fixing the script error, rebuilding and refreshing the browser corrects the problem. But not in this case.

Correcting the error and touching the app cache manifest file does correctly trigger a client-side app cache refresh in the browser (here Chrome). But my bug crashes the page before the the app cache has been refreshed and before the point where my handlers would normally swap in the update.

So you’re basically screwed in this case because the app is horked and you can’t update it by fixing the bits on the server…

Luckily chrome://appcache-internals/ can undo this evil.


About Chris Russell
This entry was posted in Internet, Software and tagged , , . Bookmark the permalink.

Comment on this article

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s