Is Safari on iOS 6 caching $.ajax results?

前端 未结 25 906
轮回少年
轮回少年 2020-11-22 09:34

Since the upgrade to iOS 6, we are seeing Safari\'s web view take the liberty of caching $.ajax calls. This is in the context of a PhoneGap application so it is

25条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 09:57

    Simple solution for all your web service requests, assuming you're using jQuery:

    $.ajaxPrefilter(function (options, originalOptions, jqXHR) {
        // you can use originalOptions.type || options.type to restrict specific type of requests
        options.data = jQuery.param($.extend(originalOptions.data||{}, { 
          timeStamp: new Date().getTime()
        }));
    });
    

    Read more about the jQuery prefilter call here.

    If you aren't using jQuery, check the docs for your library of choice. They may have similar functionality.

提交回复
热议问题