mac*_*bee 4 iis redirect caching web-config
我试图在IIS 8.5中使用301响应以及缓存到期标头(也许是具有合理到期期限的max-age或cache-control)一起开发“半永久”重定向。但是,IIS的URL Rewrite 似乎不支持将响应标头添加到重定向规则。我看到了如何在更大的范围内影响缓存,例如,但是没有如何将它们应用于单个重定向。即:
<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>
Run Code Online (Sandbox Code Playgroud)
感谢您的任何建议。我猜还有一些其他方法可以针对单个规则/路径/等执行此操作,但是找不到运气。如果不可能,那么我将不得不在更高级别上设置缓存参数。
原因:重定向指向虚荣网址;一两个月的路径相同,但此后可能会更改。Straight 301将在某些浏览器中永久缓存。302/307将导致虚荣网址被索引,这会弄乱我的SEO。
缓存响应头进入出站规则:
<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>
Run Code Online (Sandbox Code Playgroud)
结果:
提琴手截图:
这将帮助您避免使用301个永久重定向无法撤消的恐怖。我鼓励您阅读这篇出色的文章。
归功于 http://www.gillsoft.ie/using-url-rewrite-to-improve-your-site-performance-001