How to resolve json requests when using appcache HTML5 function?

When I added appcache to my webapp running under jQuery mobile, all ajax calls requesting json files from my dining room server stop. My manifest file is as follows:

CACHE MANIFEST CACHE: index.html scripts/jquery-1.7.1.min.js scripts/jquery.flot.min.js scripts/jquery.flot.threshold.min.js scripts/jquery.mobile-1.0.1.min.js styles/jquery.mobile-1.0.1.min.css styles/touchStyles.css styles/styles.css NETWORK: index.appcache dataFetchAndDraw.js initJson 

If initJson is one of the calls that will not work. I tried to enter the full address (aaa: bbb: ccc: ddd: 6565 / initJson) also without success.

In my .htaccess file, I have only one line:

 AddType text/cache-manifest .manifest 
+6
source share
3 answers

I just ran into this problem and had to add the template to the NETWORK section of the manifest file so that the browser could go online for any non-cached resources.

 NETWORK: * http://* 

To support all browsers, you apparently need both wildcard entries.

I also found appcachefacts.info a useful resource to understand this and other features of appcache. I recommend reading this to the end before continuing with the appcache learning curve:

The NETWORK section lists all URLs that can be downloaded over the Internet. If your application includes any API calls, be sure to list them here. Please note that this is a list of URL prefixes, so if all of your network calls start with http://example.com/api/ , all you need to include.

If you want to allow access to arbitrary URLs (scripts, style sheets, API calls, whatever), include *, http: // * and https: // * in this section. (Compliance with Chrome and Safari *; Firefox needs http: // * and https: // *.)

+10
source

I had a similar problem with the application I was working on, the problem was that the cache flag in the ajax call was set to true by default.

I found that when I added

 cache : false 

for my ajax GET request, the request hits the server. (http://api.jquery.com/jQuery.ajax/)

+2
source

I am throwing this problem today. But in my case, the work is done with only two steps:

  • $.ajax({ url: "/myurl", cache: false, ...})
  • NETcore Session Configuration Using

I hope this will be helpful to you.

0
source

Source: https://habr.com/ru/post/910927/


All Articles