Redirect 带缓存响应头的IIS重定向

Redirect 带缓存响应头的IIS重定向,redirect,caching,iis,web-config,Redirect,Caching,Iis,Web Config,我试图在IIS8.5中开发一个“半永久性”重定向,使用301响应和缓存过期标头,可能是一个具有合理过期时间的最大期限或缓存控制。但是,IIS的URL重写将响应头添加到重定向规则。我看到了如何在更大范围内影响缓存,但没有看到如何将它们应用于单个重定向。即: <rule name="foo" stopProcessing="true"> <match url="foo" /> <conditions> <add input="{URL}" p

我试图在IIS8.5中开发一个“半永久性”重定向,使用301响应和缓存过期标头,可能是一个具有合理过期时间的最大期限或缓存控制。但是,IIS的URL重写将响应头添加到重定向规则。我看到了如何在更大范围内影响缓存,但没有看到如何将它们应用于单个重定向。即:

<rule name="foo" stopProcessing="true">
  <match url="foo" />
  <conditions>
    <add input="{URL}" pattern="/foo($|\/$)" />
  </conditions>
  <action type="Redirect" url="http://domain.com/full_url_for_now" redirectType="Permanent" someParameterThatLetsMeSetResponseHeaders="max-age:3600"/>
</rule>


在某些浏览器中。302/307将导致虚荣URL被删除,这将扰乱我的搜索引擎优化。

缓存响应头进入出站规则:

    <outboundRules>
          <rule name="Require clients to revalidationpermanent redirects">
                <match serverVariable="RESPONSE_Cache_Control" pattern=".*" />
                <conditions>
                    <add input="{RESPONSE_STATUS}" pattern="301" />
                </conditions>
                <action type="Rewrite" value="public, must-revalidate, max-age=0"/>
            </rule>

    </outboundRules>

这将有助于你避免无法挽回的恐惧。我鼓励你阅读这篇优秀的文章

归功于

谢谢,这正是我想要的!这些文章中的许多评论建议改用302,这会损害SEO。这一解决方案似乎是正确的妥协。