A bit of a premise
Recently in the production of a Web application, which uses the HTML5 offline application function (offline application), the concept of offline applications is no longer elaborated, you can view the two articles:
http://www.ibm.com/developerworks/cn/web/1011_guozb_html5off/
Http://www.mhtml5.com/2011/02/583.html
Here is the main discussion of its update problem. First, the browser is a two-part cache, browser cache and app cache, browser cache is often said browser cache, app cache is an offline app cache.
One of the mechanisms of browser cache is clear to everyone, where the offline app update is: In addition to the first visit is to pull the server directly, and then update the app cache background, the rest of the situation is directly access to the app cache. Therefore, if the code that is applied offline is updated, it will only take effect the next time it is opened or refreshed.
Second, find the murderer
OK, the bedding is finished. My application is mainly used in the WebKit kernel browser, for the sake of convenience, the following text is produced in the environment of chrome.
When testing the offline function, we found that if you change the JS file and update the manifest, refresh two times (well, you are not mistaken, is two times, the first time in the background to update the app cache, the second application of the new cache) will apply the new code. However, after publishing to the formal environment, it can not be updated, the F5 is broken, there is no change. Of course it's okay to delete the app cache, but there's no way we can ask users to do it.
By grasping the packet discovery, no matter which environment, manifest update, browser side can crawl new, in the chrome console also can see update the app cache log, so not manifest itself is cached reasons. But in the formal environment, after pulling the new manifest, there is no updated request to go out, too weird.
Continue to compare the HTTP response headers and discover the differences, as follows:
Test environment Formal environment
http/1.1 OK http/1.1
Date:thu, 05:56:38 GMT Date:thu, Jan 2012 05:56:38 Gmt
Server:nws_hy_p91 Server:nginx
Last-modified:thu, 04:29:52 GMT Last-modified:thu, Jan 2012 04:29:52 GMT
Expires:thu, 05:56:38 GMT Expires:thu, Jan 05:56:38 GMT
Connection:close connection:keep-alive
Content-type:application/javascript content-type : nbsp , &NB Sp , &NB Sp application/javascript
Vary:accept-encoding cache-control:max- age=10368000
As you can see, there are 3 different, connection, vary, cache-control in the two environments. At first glance, the feeling may be a cache-control problem. So with Fildder the response stuck, the max-age changed to 0, the result, it normal update! So guess the app cache update should be to go to browser cache first, found the file, and did not expire, no longer access to the server, so the capture package also can not see any request.
HTML5 offline application can not update the location and resolution