IIS - Cache Control must-revalidate"

Reference : Deploying to Microsoft Internet Information Server (IIS) | Gatsby (gatsbyjs.com)


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <location path="static">
        <system.webServer>
            <httpProtocol>
                <customHeaders>
                    <remove name="cache-control" />
                    <add name="cache-control" value="public, max-age=31536000, immutable" />
                </customHeaders>
            </httpProtocol>
        </system.webServer>
    </location>
    <location path="page-data">
        <system.webServer>
            <httpProtocol>
                <customHeaders>
                    <remove name="cache-control" />
                    <add name="cache-control" value="public, max-age=0, must-revalidate" />
                </customHeaders>
            </httpProtocol>
        </system.webServer>
    </location>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
        </staticContent>
        <rewrite>
            <outboundRules>
              <rule name="AdjustCacheForDontCacheFiles" preCondition="IsDontCacheFile" stopProcessing="true">
                <match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
                <action type="Rewrite" value="public, max-age=0, must-revalidate" />
              </rule>
              <rule name="AdjustCacheForCachePermanentlyFiles" preCondition="IsCachePermanentlyFile" stopProcessing="true">
                <match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
                <action type="Rewrite" value="public, max-age=31536000, immutable" />
              </rule>
              <preConditions>
                <preCondition name="IsDontCacheFile">
                  <add input="{REQUEST_FILENAME}" pattern="(.*\.html)|(sw\.js)|(app\-data\.json)|(page\-data\.json)" />
                </preCondition>
                <preCondition name="IsCachePermanentlyFile">
                  <add input="{REQUEST_FILENAME}" pattern="((.*\.js)|(.*\.css))$" />
                </preCondition>
              </preConditions>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

0 comments:

 
Copyright © peyotest