哪些浏览器缓存XMLHTTPRequest响应有问题? [英] Which browsers have problems caching XMLHTTPRequest responses?

查看:219
本文介绍了哪些浏览器缓存XMLHTTPRequest响应有问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何目前流行的浏览器在缓存* XMLHttpRequest响应时都有特别的问题,我需要注意吗?

Do any of the currently popular browsers have particular problems caching* XMLHttpRequest responses that I need to be aware of?

我想能够包含XMLHttpRequest每个页面上的查询作为动态加载与页面类型相关的内容(即JSON)或行为(如eval()ed Javascript)的方法,但希望确保从服务器接收的资源可以缓存,如果服务器发送了正确的标头。

I'd like to be able to include XMLHttpRequest queries on every page as a method of dynamically loading content (ie JSON) or behaviour (like eval()ed Javascript) relevant to the type of page, but wanted to make sure that the resources it receives from the server could be cached, if the server sent the right headers.

我关心的是阅读这篇文章提到,浏览器,如Firefox 1.1不缓存任何通过XMLHTTPRequest获得的内容,它总是请求新的数据完全发送(使用Cache-Control和

I was concerned to read this article which mentions that browsers such as Firefox 1.1 do not cache any content obtained via XMLHTTPRequest, and that it always requests new data is sent completely (with Cache-Control and no If-Modified-Since) regardless of headers sent by the server.

很明显,文章很古老 - 我甚至不记得Firefox 1.1;那么当前流行的浏览器需要考虑哪些因素?当我特别想要响应被缓存时,有什么窍门吗?

Obviously that article is very old - I don't even remember a Firefox 1.1; so what are the considerations I need to make for current popular browsers and is there any trick for when I specifically want responses to be cached?

**为了澄清我的问题,通过缓存,我的意思是客户端缓存,其中服务器发出新鲜信息(以Cache-Control:max-age指令或Expires:头的形式),浏览器存储一个副本在其高速缓存中的响应以及到期日期,使得从后续页面发出的对相同资源的未来请求可以从浏览器高速缓存满足,而根本不需要与服务器的任何联系。所有主要的浏览器对大多数内容都正确地做到这一点,但我听说Firefox不能这样做XMLHttpRequest内容。我要问的是,如果有人知道任何现代浏览器在使用XMLHttpRequest时不根据规范缓存响应的情况。

**To clarify my question, by caching, I mean client-side caching, where the server issues freshness information (in the form of a Cache-Control: max-age directive or an Expires: header) and the browser stores a copy of the response in its cache along with an expiry date, so that future requests for the same resource issued from subsequent pages can be satisfied from the browser cache without the need for any contact with the server at all. All major browsers do this correctly for most content, but I've heard that Firefox cannot do this for XMLHttpRequest content. What I'm asking is if anyone knows of cases where any of the modern browsers do not cache responses according to the spec when using XMLHttpRequest.*

推荐答案

Mark Nottingham有一系列功能测试,证明浏览器XMLHttpRequest缓存行为。在您要支持的浏览器中加载页面,并确定您可以和不能依靠的技术来缓存您的响应。

Mark Nottingham has an excellent set of functional tests that demonstrate browser XMLHttpRequest caching behaviour. Load up the page in the browsers you want to support and work out what techniques you can and cannot rely on to have your response cached.

这篇关于哪些浏览器缓存XMLHTTPRequest响应有问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆