将jQuery ajax缓存,即使php头发出相反


Will jQuery ajax cache even if php headers are issued to the contrary?

http://api.jquery.com/jquery.ajax/声明缓存的默认值是true,如果设置为false,它将强制请求的页面不被浏览器缓存。

如果cache被设置为true,但服务器返回一些报头声明不缓存,客户端还会尝试使用缓存的结果吗?有一些浏览器在这方面有不同的行为吗?

<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>

如果您关心缓存,cache:true所做的是为url添加时间戳。

这使得它是一个唯一的url,因此浏览器几乎不可能缓存,因为浏览器将没有对该url的引用

关于客户端是否会尝试缓存结果,如果服务器发出不这样做的标头,"实际上它应该工作",客户端不会缓存结果