避免301重定向缓存 [英] Avoiding 301 redirect caching

查看:165
本文介绍了避免301重定向缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是对使用301/303的跟进问题/ 307重定向动态短网址,在此我尝试确定在目标网址频繁更改的情况下实现短网址重定向的最佳方法。

This is a follow up question to Using 301/303/307 redirects for dynamic short urls, where I try to determine the best method for implementing short url redirection when the destination url will change on a frequent basis.

虽然301和307重定向似乎都以相同的方式执行,但与我有关的问题是301重定向缓存(如这里)-是避免这种情况的最佳方法,而是使用307重定向(我假设307重定向将永远不会缓存?),或显式发送没有缓存的标头(缓存控制:没有缓存,必须重新验证)?

While it seems that 301 and 307 redirects both perform the same way, the issue that concerns me is 301 redirect caching (as documented here)- is the best way to avoid this to use 307 redirects instead (I'm assuming 307 redirects will never cache?), or to explicitly send a no-cache header ("Cache-Control: no-cache, must-revalidate")?

推荐答案

不要尝试以避免301缓存。如果您不希望任何用户代理缓存您的重定向,则只需不要使用301重定向。换句话说,301缓存将保留下来,从语义上讲,这是永久重定向,因此,如果您打算更改目标URL,则301不是正确的状态代码。另一方面,默认情况下, 307个响应未默认缓存

Don't try to avoid 301 caching. If you don't want any user agent to cache your redirect, then simply don't use a 301 redirect. In other words, 301 caching is here to stay, and semantically, it's a permanent redirect, so if you're planning to change the destination URL, 301 is not the right status code to use. On the other hand, 307 responses are not cached by default.

这篇关于避免301重定向缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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