IIS redirect with cache response header

I am trying to develop β€œsemi-persistent” redirects in IIS 8.5 using answer 301 along with the cache expiration header (s), possibly the maximum age or cache management with reasonable expiration. However, the IIS URL Rewrite does not seem to support it by adding response headers to the redirect rule. I see how to influence the cache in a larger area like this , but not how to apply them to individual redirects. I.e:.

<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>

Thanks for any advice. I suppose there is another way to do this for individual rules / paths / etc., But no luck finding it. If this is not possible, I will have to set the cache settings to a higher level.

Why: redirection is for vanity URLs; the path will be the same for a month or two, but may change after that. In some browsers, Straight 301 will cache continuously . 302/307 will cause the vanity URL to be indexed , which will ruin my SEO.

+4
source share
1 answer

The cache response header is in the outbound rules:

    <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>

Result:

Fiddler Screenshot:

enter image description here

This will help you to avoid the horror that cannot be undone with 301 permanent redirects . I recommend you read this wonderful article.

http://www.gillsoft.ie/using-url-rewrite-to-improve-your-site-performance-001

+4

Source: https://habr.com/ru/post/1626251/


All Articles