重定向的浏览器缓存行为
我试图弄清楚将所有 www.example.com 请求重定向到 example.com 是否有利于缓存,为此我有两个问题。 SEO在这里不是问题。
如果浏览器从 www URL (#1) 请求图像并获得 HTTP 重定向到无 www 版本 (#2),它会将结果存储为仅 #2 或 #1 的缓存值.
浏览器偶尔会请求图像的新版本(并且可能会得到它,或者“未修改”响应)。这样就会产生每次都必须处理重定向的开销。这个开销是否比存储同一图像的两个版本的成本更大?浏览
I'm trying to figure out if redirecting all www.example.com requests to example.com will be beneficial for caching or not, to which end I have 2 questions. SEO is not an issue here.
If the browser requests an image from the www URL (#1) and gets HTTP redirected to the www-less version (#2), will it store the result as cache value for just #2, or #1 as well.
The browser will occasionally ask for a new version of the image (and might get it, or a "Not Modified" response). There will then be an overhead for having to process the redirect every time. Is this overhead larger than the cost of storing two versions of the same image?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果浏览器从 www URL (#1) 请求图像并获得 HTTP 重定向到无 www 版本 (#2),它是否会将结果存储为仅 #2 或 # 的缓存值1 也是如此。
@:请参阅 301 的 W3C 状态代码定义。如果这是一个 301 重定向,它“应该”是可缓存的。请参阅如何重定向网页 (301)。< /em>
浏览器偶尔会请求图像的新版本(并且可能会得到它,或者“未修改”响应)。这样就会产生每次都必须处理重定向的开销。此开销是否大于存储同一图像的两个版本的成本?
@:我不太确定这一点,我想如果重定向是由网络服务器(IIS、apache 等)处理的,那么开销应该是最小的。不过,请不要引用我的话:P
If the browser requests an image from the www URL (#1) and gets HTTP redirected to the www-less version (#2), will it store the result as cache value for just #2, or #1 as well.
@: See W3C Status Code Definitions for 301. If it's a 301 redirect, it 'should' be cacheable. See How to Redirect a Web Page (301).
The browser will occasionally ask for a new version of the image (and might get it, or a "Not Modified" response). There will then be an overhead for having to process the redirect every time. Is this overhead larger than the cost of storing two versions of the same image?
@: I'm not exactly sure of this, I suppose if the redirect is handled by the webserver (IIS, apache etc), the overhead should be minimal. Don't quote me though :P