Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cache manifest offline app not refreshing javascript files in Chrome

I am working on an offline web app using a cache manifest file. I am having trouble refreshing my javascript files. If I change a .js file (which is listed in the manifest file) and I then change the manifest file version no. and save it, then the changed .js file does not get reloaded on the client. What do I have to do to get .js files to refresh?

Thanks

like image 813
Journeyman Avatar asked May 03 '11 13:05

Journeyman


2 Answers

That's because the webserver tells the browser cache static files for a few hours. So the browser doesn't know the manifest file is changed. You can clear all the application data 'or' config the web server the manifest is not cacheable...

Read http://diveintohtml5.info/offline.html for more info

If you want to clear your app cache on chrome use chrome://appcache-internals/ and by hand you have to search in C:\Documents and Settings\YOURUSERNAME\Local Settings\Application Data\Google\Chrome\User Data\Default\Cache

like image 70
amernov Avatar answered Oct 14 '22 11:10

amernov


I had assumed that you if you use a cache manifest and then refresh the manifest, that the browser would request all of the files again. However, I have found that I needed to explicitly set headers in all of the files in the manifest to tell the browser not to cache the files. I believe that once the manifest tells the browser to request the file again, the browser treats it like any other non-manifest cached file. Maybe this is an error with Chrome, but I feel like I saw this in another WebKit browser.

Regardless, set the headers for the files in the manifest to never be cached and they should reload when you update the manifest. If these files are used outside of a manifest page, you may need to actually cache the files depending on your needs.

like image 35
B. Melonis Avatar answered Oct 14 '22 13:10

B. Melonis