~Onlooker 2012-09-19 22:07 采纳率: 0%
浏览 329

6 caching / . Ajax 检测结果?

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 using the Safari WebView. Our $.ajax calls are POST methods and we have cache set to false {cache:false}, but still this is happening. We tried manually adding a TimeStamp to the headers but it did not help.

We did more research and found that Safari is only returning cached results for web services that have a function signature that is static and does not change from call to call. For instance, imagine a function called something like:

getNewRecordID(intRecordType)

This function receives the same input parameters over and over again, but the data it returns should be different every time.

Must be in Apple's haste to make iOS 6 zip along impressively they got too happy with the cache settings. Has anyone else seen this behavior on iOS 6? If so, what exactly is causing it?


The workaround that we found was to modify the function signature to be something like this:

getNewRecordID(intRecordType, strTimestamp)

and then always pass in a TimeStamp parameter as well, and just discard that value on the server side. This works around the issue. I hope this helps some other poor soul who spends 15 hours on this issue like I did!

转载于:https://stackoverflow.com/questions/12506897/is-safari-on-ios-6-caching-ajax-results

  • 写回答

25条回答 默认 最新

  • perhaps? 2012-09-19 23:34
    关注

    I just had this issue as well in a PhoneGap application. I solved it by using the JavaScript function getTime() in the following manner:

    var currentTime = new Date();
    var n = currentTime.getTime();
    postUrl = "http://www.example.com/test.php?nocache="+n;
    $.post(postUrl, callbackFunction);
    

    I wasted a few hours figuring this out. It would have been nice of Apple to notify developers of this caching issue.

    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥30 ABAQUS 实体单元如何在分析步中分步多次施加绕某轴的运动?
  • ¥15 docker部署redis集群,springboot启动报错DefaultClusterTopologyRefresh,而且第一个节点的IP也变了
  • ¥15 关于延迟常微分方程DDE的分岔图
  • ¥15 putimage函数输出错误
  • ¥15 进行刷新动态页面和点击进入一个动态,会包含在一个网络五元组会话内吗
  • ¥20 绘制风向风速时间序列
  • ¥15 Revit二次开发高程点标注问题
  • ¥15 两道题,用python写出代码
  • ¥15 该怎么把前导 0 去掉存储给点思路
  • ¥15 智能循迹小车的红外模块无法给单片机输出信号或者是单片机无法输入信号,如何解决?(语言-c语言)
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部