Possible Duplicate:
Is Safari on iOS 6 caching $.ajax results?
I have a hybrid application using PhoneGap
that runs fine on Android and iOS. But when I started testing in iOS 6 I noticed that I am not getting server data for most of my ajax calls - instead I was getting the cached data from previous ajax calls.
So far I have tried the following options to disable cache -
- Include a timestamp as query string parameter
$.ajaxSetup({ cache: false });
- Inside the ajax call
no-cache = true
$.ajaxPrefilter(function (options, originalOptions, jqXHR) { options.data = jQuery.param($.extend(originalOptions.data||{}, { timeStamp: new Date().getTime() })); });
But none of these seems to be working. I am invoke Java action classes from my ajax calls - will it have something to do with the reason why the methods listed above are failing?
From here
How to fix it: There are various methods to prevent caching of requests. The recommended method is adding a no-cache header.
This is how it is done.
jQuery:
Check for iOS 6.0 and set Ajax header like this.
ZeptoJS :
Check for iOS 6.0 and set Ajax header like this.
Server side
Java :
Make sure to add this at the top the page before any data is sent to the client.
.NET
Or
PHP
Read this thread
Is Safari on iOS 6 caching $.ajax results?
You could disable the caching on webserver level and by using timestamps in the URL.