Cache manifest offline app not refreshing javascript files in Chrome

♀尐吖头ヾ 提交于 2019-12-10 02:23:46

问题


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


回答1:


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




回答2:


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.




回答3:


Type chrome://appcache-internals in your address bar then click ENTER

A list of cached manifests will appear then just delete the one you want and everything will be refreshed when you load your page again.

Hope this helps :)




回答4:


I had the same problem until I came across this priceless warning on the Mozilla Developer site

Important: Do not specify the manifest itself in the cache manifest file, otherwise it will be nearly impossible to inform the browser a new manifest is available.

woops. my bad.

However, every time I change something in the code, I need to change something in the manifest, and then reload twice, which is an unrelated issue.




回答5:


In my case, i has to disable the traditional browser cache using meta tags. See this SO question how to that



来源:https://stackoverflow.com/questions/5870300/cache-manifest-offline-app-not-refreshing-javascript-files-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!