Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.applicationCache updates freeze browser - how to reduce their frequency or force them to be user-initiated

I've created a web app that caches all necessary code and data for use offline through applicationCache. However, every time the app starts up, it immediately tries to check for updates. This blocks the browser for a significant chunk of time, even if it doesn't find anything to update. This behavior is highly disruptive to the app (shouldn't updates be done in the background, anyway?). Just the checking stage takes a lot of time on a mobile device, and if it find updates all bets are off as to how long downloading will take (b/c it has to redownload all files) - which also freezes up the browser.

So, I am wondering:

  1. Is there a way to delegate applicationCache updates to a shared Web Worker? OR
  2. Is there a way to block all applicationCache updates until the user specifically wants to check for updates and presses a button that will initiate updates through applicationCache.update()? OR
  3. Are there other ways to mitigate the time spent on checking for updates?
  4. Shouldn't application cache updates run asynchronously in the background?



edit: perhaps a carefully-constructed cache-control header on the manifest file is the answer? I'll be investigating this, but I hope somebody can give me more info on these updates. Thanks.


UPDATE

Ok, I've played with headers, and nothing has helped. I'm starting a bounty. If you can help, please do!

like image 944
ampersand Avatar asked Nov 14 '22 23:11

ampersand


1 Answers

If you want to give the user more control over the actual update, you could parameterise the manifest URL with something specific to that user. Then when the user wants to update, you fire off a request to the server which rolls that particular user's manifest file, and then reload the page client-side to force a reload of the manifest.

I've since been doing some reading and came across this article which seems to be a much more elegant solution if the user is already on the cached page -

http://www.html5rocks.com/tutorials/appcache/beginner/#toc-updating-cache

As for the load time involved in the manifest up-to-date check, that's not something I've ever had a problem with. My understanding was that it happens in the background, are you just concerned about the browser showing loading hints?

like image 138
Chris Avatar answered Nov 16 '22 16:11

Chris