I am having an issue with ajax caching, This was a problem in IE browser too but i fixed it by Writing the Following code.

我有一个ajax缓存的问题,这也是IE浏览器的问题,但是我通过编写以下代码来修复它。

    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("expires","-1");
    response.setHeader("pragma","no-cache");

But I see Safari4.0 on MAC is Caching the Ajax request(We have a requirment to support this). Fire Fox never a problem. Regarding this "Expire" i am setting it to -1, i see lot of places it is set 0 or some old date from past. Will it make a difference?

但是我看到MAC上的Safari4.0正在缓存Ajax请求(我们有一个请求来支持这个请求)。火狐狸从来都不是问题。关于这个“Expire”,我将其设置为-1,我看到很多地方将其设置为0或以前的日期。会有不同吗?

3 个解决方案

#1


13

Send an extra parameter with your GET request that will never be the same, for example, the current timestamp. Something like:

用GET请求发送一个额外的参数,这个参数永远不会是相同的,例如当前时间戳。喜欢的东西:

url = url + '&nocache=' + new Date().getTime();

This will prevent caching.

这将防止缓存。

更多相关文章

  1. 在传递给google.setOnLoadCallback()的函数中使用参数;
  2. Js的Url中传递中文参数乱码,如何获取Url中参数问题
  3. Javascript setTimeout 带参数延迟执行 闭包实现
  4. 如何使用jQuery在GET请求中传递参数
  5. 在javascript中调用带有双参数()的函数
  6. ajax请求中URL和参数的编码问题
  7. 我可以在JavaScript中从不同的页面传递参数吗?
  8. JavaScript:使用函数参数检索javascript对象键
  9. Js中获取超链接里面传递的参数值

随机推荐

  1. Android 5.0(L) 的MediaSession架构分析(
  2. android通知栏提示
  3. Android 获取Sim卡联系人
  4. Android改变MAC地址
  5. Stuff about Android
  6. Android 自动更新代码
  7. BBC发布了android客户端应用
  8. Android 键盘设计
  9. Android FTP Server
  10. Build your first Android Application w