javascript - Application cache manifest - Content gets updated on server but client does not show updated content -


First of all, I'm sorry about English, I'm not good at English.

  • If the server is updating the contents of the page (html), then I click the F5 button to reload this page on the client, this page will display updated content. . How to do this?
  • And I have a Jason file, this page has a button when I click the button, the contents of the json file will show. If I have edited this json file, then I will reload the page and click on this button, this will show the edited json file. How to do this?
  • I used the cache manifest, when I changed the content of the page on the server, and reloaded the page in the client, the client could not change the content.

I executed it on Firefox 30, it has failed. But it's great on Google Chrome.

cache_test.html:

  & lt ;! DOCTYPE html & gt; & Lt; Html lang = "ja" manifest = "test.appache" & gt; & Lt ;! - & lt; Html lang = "ja" manifest = "test.manifest" & gt; - & gt; & Lt; Top & gt; & Lt; Meta charset = "UTF-8" /> & Lt; Meta name = "viewport" content = "width = device-width, initial-level = 1, minimum-level = 1, maximum-level = 1, user-scalable =" / " & Lt; Script src = "jquery-2.1.1.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "test.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ (Function () {updateAppCache ();}); & Lt; / Script & gt; & Lt; Title & gt; Cash Test & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; Cash Test v15 & lt; Br> & Lt; Button onClick = "loadJSON ('msg')" & gt; Load Jason & lt; / Button & gt; & Lt; Div id = "msg" & gt; & Lt; / Div & gt; & Lt; Br> & Lt; A href = "test.html" & gt; Test.html & lt; / A & gt; & Lt ;! - & lt; Img src = "1.jpg" & gt; - & gt; // I want to edit the content, it will be shown on the client; & Lt; Img src = "2.jpg" & gt; - & gt; // The content I want to edit will show on the client & lt; Img src = "3.jpg" & gt; & Lt; Img src = "4.jpg" & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

test.js:

  function loadJSON (idMsg) {jQuery.ajax ({url: 'test.json', type: 'GET', Success: function (data, textstats, exhaor) {$ ('#' + idmg) .text ('Load Success:' + JSON.stringify (Data)); Error: Function (xhr, textStatus, errorThrown) {$ ('#' + IdMsg) .text ('Error to Load:' + Textstats);}}); } Function updateAppCache () {// View: http://www.html5rocks.com/ja/tutorials/appcache/beginner/ console.log ('updateAppCache - in'); Var appCache = window.applicationCache; // Update AppCache appCache.update (); // Once you are ready to update the cache, call swap apache.AdventList ('Updaterier', function (e) {// manifest changes) (Apkach.Status === App Cache .UPDATEREADY) {appCache. SwapCache (); console.info ('Swap cache. AppCache status =' + appCache.status); // Reload page window.Reload (true);} and {console.warn ('do not swap cache . AppCache status = '+ app cache.thetas);}}, false); }  

test.appcache:

  CACHE MANIFEST # 2014-07-13: v15 # AddType text / cache-manifest .appcache #Current Cached Master Entries' Cache_test.html jquery-2.1.1.min.js test.json test.js test.html # 1.jpg // I want to save the content in the application cache on the client. # 2.jpg // Content I want to save on the client in the application cache. 3.jpg 4.jpg # For resources, users must be online: Networks: Fallback:  

test.json:

  {"test": "What is happening to man!?", "Foo": "--- ------"}  

I want to edit the contents of the Jason file:

  {"test": "What's the guy going?!", "Foo": "I always love you"}  

When using some cache (HTML, Image, CSS, Javascript) server changes, Una need to modify the requested URL to force loading. For example:

The original url is:
test.html After modifying the content, the html will definitely be completely reloaded in the
browser, you see a change in firebug You can.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -