doremi
doremi

Reputation: 15329

Using Ajax with Offline Cache

I'm working on an offline-capable application and I'd like to do an ajax call to $.get() a file on the domain that I will be caching.

Will the call still work if I'm offline? I would presume no, but I wondered if I included the static page in the offline cache if it would somehow still work.

Upvotes: 5

Views: 6659

Answers (2)

Ohad Kravchick
Ohad Kravchick

Reputation: 1154

You can cache the responses into local storage and use the saved one when offline. See more on how to make this automatic here: http://myok12.wordpress.com/2011/08/19/building-an-almighty-data-retrieval-system-for-all-html5-webapps/

Upvotes: 1

mgiuca
mgiuca

Reputation: 21357

Short answer: Yes.

If you have the file in the application cache, then all HTTP GET requests (including Ajax) will go through the cache. You can think of an Ajax GET request as an ordinary browser page load, but the results are delivered to your code rather than directly to the user.

Upvotes: 5

Related Questions