4

I am developping a HTML5 application. I cache all the files thanks to the .manifest solution, so the app can be used when you don't have access to Internet.

I want to synchronise some data to the server whenever it is possible. Since the variable navigator.online seems to not be reliable enough, I do an AJAX request (using jQuery.get()) to detect if I get something in response, meaning the user is online.

The problem is that, as soon as the whole application is cached, every AJAX request towards a file on Internet fails with no reason. I tried on Chrome, Firefox, and Safari (on iPad) with the same result.

I use jQuery.get() to get the content of some files that are part of the application (and cached at the same time), these requests work flawlessly.

I first tought of a Same-origin problem. So I tried to do a request to https://graph.facebook.com, just to see if I get anything in return. In the Chrome console, the request status is "Pending", with 0bytes received.

When I deactivate the manifest and empty the cache, there is no problem at all.

Do you have any idea or hint on why this is happenning ?

Thank you :)

PS : English isn't my mother tongue, so please excuse (and feel free to correct) any mistakes I might have made. :)

Benjamin C.
  • 1,076
  • 12
  • 20
  • `.get()` is a comfortable shorthand. But for better control over the request try [`.ajax()`](http://api.jquery.com/jQuery.ajax/), or use `.get()` with [`.ajaxSetup()`](http://api.jquery.com/jQuery.ajaxSetup/) – Boaz Nov 21 '13 at 10:59

1 Answers1

2

Check that you have the network section. The network section of a cache manifest file specifies resources for which a web application requires online access. * is a wildcard which matches all.

CACHE MANIFEST
# 2013-11-21:v1

CACHE:
/Content/Site.css
/Scripts/jquery-1.8.2.js

NETWORK:
*

FALLBACK: 
/ /Home/Offline
LostInComputer
  • 15,188
  • 4
  • 41
  • 49
  • Note: after updating the manifest, you have to refresh your browser twice if your code doesn't call swapCache() – LostInComputer Nov 21 '13 at 14:11
  • And what about ajax calls to other domains? (either allowed by the Access-Control-Allow-Origin header, or made via jQuery's ajax jsonp type). I cannot perform this requests, and apparently putting the cross origin url in the NETWORK section of the cache manifest does not work either, as opposed to when you put * or any other entry in my own domain. – Ernesto Jan 09 '15 at 18:28