IIS 重定向缓存响应 header
IIS redirect with cache response header
我正在尝试在 IIS 8.5 中使用 301 响应以及缓存过期 header(s),可能是 max-age 或 cache-control 开发一个 "semi-permanent" 重定向合理到期。但是 IIS 的 URL Rewrite doesn't seem to support adding response headers to a redirect rule. I see how to affect the cache at a larger scope, like this,但不是如何将它们应用于个别重定向。即:
<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>
感谢您的任何建议。我猜还有一些其他方法可以为个人 rules/paths/etc 执行此操作,但没有找到它。如果实在不行,那我就得把缓存参数调高了。
原因:重定向是出于虚荣心 URL;该路径将在一两个月内保持不变,但之后可能会发生变化。直接 301 会 cache permanently in some browsers. 302/307 will cause the the vanity URL to be indexed,这会弄乱我的 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>
结果:
Fiddler 截图:
这将帮助您避免 301 permanent redirects 无法消除的恐怖。我鼓励您阅读这篇优秀的文章。
归功于
http://www.gillsoft.ie/using-url-rewrite-to-improve-your-site-performance-001
我正在尝试在 IIS 8.5 中使用 301 响应以及缓存过期 header(s),可能是 max-age 或 cache-control 开发一个 "semi-permanent" 重定向合理到期。但是 IIS 的 URL Rewrite doesn't seem to support adding response headers to a redirect rule. I see how to affect the cache at a larger scope, like this,但不是如何将它们应用于个别重定向。即:
<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>
感谢您的任何建议。我猜还有一些其他方法可以为个人 rules/paths/etc 执行此操作,但没有找到它。如果实在不行,那我就得把缓存参数调高了。
原因:重定向是出于虚荣心 URL;该路径将在一两个月内保持不变,但之后可能会发生变化。直接 301 会 cache permanently in some browsers. 302/307 will cause the the vanity URL to be indexed,这会弄乱我的 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>
结果:
Fiddler 截图:
这将帮助您避免 301 permanent redirects 无法消除的恐怖。我鼓励您阅读这篇优秀的文章。
归功于 http://www.gillsoft.ie/using-url-rewrite-to-improve-your-site-performance-001