Configure browser caching in DXC/Azure environment

  • Updated
The following settings need to be placed in the Web.config
 
<configuration>
        <system.webServer>
                <staticContent>
                        <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
                </staticContent>
        </system.webServer>
</configuration>
 
 
<configuration>
        ...
        <configSections>
                ....
                <section name="staticFile" type="EPiServer.Framework.Configuration.StaticFileSection, EPiServer.Framework" allowLocation="true" />
        </configSections>
</configuration>
 
The below setting may also be needed if you want to leverage the globalasset's static files
<configuration>
        ...
        <location path="GlobalAssets">
                <staticFile expirationTime="7.00:00:00" cacheControl="Public"/>
        </location>
</configuration>
 
<resizer>
    <clientcache minutes="10080" />
    <plugins>
    <add name="EPiFocalPointPlugin" />
    <add name="EPiServerBlobReaderPlugin" />
    </plugins>
  </resizer>
 
(The clientcache setting for <resizer> will impact on the kind of static assets like https://www.example.com/globalassets/images/test.jpg?maxwidth=787&maxheight=875)
 
We can also specify different caching durations for different types of assets, for example:
<location path="SiteFolder/Static/build/js">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" setEtag="true" />
      </staticContent>
    </system.webServer>
  </location>
 
Restart the web app
Clear Cloudflare CDN