Hax*_*lit 16 javascript jquery google-chrome
我正在使用谷歌浏览器,我注意到每次执行XHR请求时,我都会在请求中添加以下标头:
Cache-Control: no-cache
Pragma: no-cache
Run Code Online (Sandbox Code Playgroud)
如果您阅读http://www.w3.org/TR/XMLHttpRequest/上的规范,则说明以下内容
如果用户代理实现HTTP缓存,则它应该尊重作者请求头中的Cache-Control头(例如,Cache-Control:no-cache绕过缓存).除非最终用户明确请求此类行为(例如,通过重新加载页面),否则它不能自动发送Cache-Control或Pragma请求标头.
好吧,我正在尝试以下方法:
$.ajax(myUrl, {
type: 'get',
dataType: 'json'
cache: true,
headers: {
'Cache-Control': 'max-age=200'
}
})
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我明确地设置了Cache-Control标头,希望获得我的资源的缓存副本.好吧Chrome似乎忽略了Cache-Control标头.
Cache-Control: no-cache在发出XHR请求时是否可以不发送标头?