Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript Ajax jQuery , +
Hi All,
i am developing an web application when i tested it on Safari browser in IOS 6 version.On every request its fetching same cache results .
Is it a browser problem.If it not help me in clearing the cache in java script/J query.
 
Thanks in advance
Posted 15-Jan-13 19:58pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Have you explicitly set cache to false in ajax call?
 
$.ajax({
  url: "test.html",
  cache: false,
  success: function(data){
    //some processing
  }
});
 

 
http://api.jquery.com/jQuery.ajax/[^]
  Permalink  
Comments
Tharaka MTR at 16-Jan-13 2:28am
   
I tried this, but it didn't work for me.
Vyacheslav Voronenko at 16-Jan-13 2:35am
   
Ooops! I missed that it is IOS6! Apple ignores the rules, and uses it's own caching policy. Common workaround, is to add some fake unique parameter to query (for example current date and time).
 
Proof:
http://arstechnica.com/apple/2012/09/developers-claim-safari-in-ios-6-breaks-web-apps-with-aggressive-caching/
 
Another option, like correctly mentioned A Patra - set to no-cache:
 
No Cache-Control or Expires headers = iOS6 Safari will cache
Cache-Control max-age=0 and an immediate Expires = iOS6 Safari will cache
Cache-Control: no-cache = iOS6 Safari will NOT cache
 
Tharaka MTR at 16-Jan-13 2:38am
   
Yep.
ravithejag at 16-Jan-13 5:33am
   
thanks Vyacheslav
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

It happens when you make a httpget request.actually by default cache is set to true .you need to use some attribute like:
apply this attribute to your controller or action
 
[OutputCache(Duration=0,NoStore=true)]
 
here the cache duration is set to 0 and nostore property says that cached data will not be stored at client side.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can also set the following parameters in your asp.net page so that it will not get cached in the client browser
 
Response.Buffer = True
Response.ExpiresAbsolute = Now().Subtract(New TimeSpan(1, 0, 0, 0))
Response.Expires = 0
Response.CacheControl = "no-cache"
 
Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

This is exactly iOS6 breaking change.
 
Safari on iOS6 will cache POSTs that have either no Cache-Control headers or even "Cache-Control: max-age=0".
 
I also experienced with this issue and fix as follows.
In your web service method, please add the following line
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
ex:
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void HelloWorld()
{
	HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
 
}
 

if you need any more information please check in following thread.
http://stackoverflow.com/questions/12506897/is-safari-on-ios-6-caching-ajax-results[^]
  Permalink  
Comments
ravithejag at 16-Jan-13 3:38am
   
Thanks Tharaka
Tharaka MTR at 16-Jan-13 4:09am
   
if you get the answer, it is best practice to mark as answer. then thread will be closed.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

use these tags in Page
 
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 503
1 George Jonsson 311
2 CPallini 290
3 OriginalGriff 139
4 Prasad Khandekar 135
0 OriginalGriff 4,623
1 CPallini 3,410
2 Sergey Alexandrovich Kryukov 2,929
3 George Jonsson 2,319
4 Gihan Liyanage 2,077


Advertise | Privacy | Mobile
Web02 | 2.8.140905.1 | Last Updated 9 Aug 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100