2

I have a mvc 3 razor project that on pc is working very good there are one problem on Ipad I have a list of artikel and a added button for test then i press added button it is return the date time now then i press the added buttom it is return a date time, then I press the second time it is return the same date time, my project on Ipad is taked value from cache I think, can every one help me??? This jquery code:

$(document).ready(function (){        
    $(".AddButton").live("click", function(){                
        var buttonId = $(this).attr("id");                
        var id = buttonId.substr(buttonId.indexOf("_"));
        $.ajax({                
            type:'POST',
            dataType:'json',                
            url: "@Url.Action("AddCommandArtikelJson","Home")",
            data: {id:$("#Id"+id).val(), id_priceOnPad: $(this).attr("name")},
            cache: false,
            success: function(result){            
                $("#commandsCount").text(result);
            }
        });

    });
});

and this controller function:

 [HttpPost]
    public JsonResult AddCommandArtikelJson(int id, int id_priceOnPad)
    {//my code
         return Json(DateTime.Now);
    }
Moraru Viorel
  • 350
  • 1
  • 16

2 Answers2

4

A common trick in this kind of situations is to pass a random string in the querystring, This tricks the browser to think that the request is different and therefore you bypass the cache.

Luis
  • 5,979
  • 2
  • 31
  • 51
3

I came across this very same issue when a .NET site I worked on was caching web service requests to such an extent that it was affecting my site functionality. This seems to be a common trait in iOS6.

This StackOverflow post should help you: Is Safari on iOS 6 caching $.ajax results?

I have written some blurb on my experiences on this issue: http://www.isurinder.com/blog/post/2012/09/24/iOS-Safari-Browser-Has-A-Massive-Caching-Issue!.aspx

By passing a full time-stamp to your service should solve your problems.

Community
  • 1
  • 1
SurinderBhomra
  • 2,169
  • 2
  • 24
  • 49