Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • bh 174 posts 596 karma points
    1 week ago
    bh
    0

    My higher-ups asked me to address issues we have with elements of our umbraco website caching in the browser.

    So I started with gulp-cachebust to hash the filenames of my *.css and *.js files. I'm very happy with the results there.

    Next I wanted to attack HTML caching. And this is where I'm not sure how to proceed. As you can see from my screengrab below, my homepage cache-control is set to private. I think maybe that should be set to no-cache. Also, there's no ETag header. I think adding an ETag header might help.

    Here's my relevant web.config code:

    <staticContent>
          <remove fileExtension=".air" />
          <mimeMap fileExtension=".air" mimeType="application/vnd.adobe.air-application-installer-package+zip" />
          <remove fileExtension=".svg" />
          <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
          <remove fileExtension=".woff" />
          <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
          <remove fileExtension=".woff2" />
          <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" />
          <remove fileExtension=".less" />
          <mimeMap fileExtension=".less" mimeType="text/css" />
          <remove fileExtension=".mp4" />
          <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
          <remove fileExtension=".json" />
          <mimeMap fileExtension=".json" mimeType="application/json" />
          <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
        </staticContent>
    

    Is it possible/advisable to use UseMaxAge for my static elements in the mimeMaps you see in my code, and use no-cache for my *.aspx and *.cshtml?

    enter image description here

  • bh 174 posts 596 karma points
    1 week ago
    bh
    100

    Ended up using an outbound rewrite rule to add the no-cache header to my html files while maintaining my UseMaxAge on my static content.

    <outboundRules>
                <rule name="RewriteCache-Control" preCondition="IsHTML">
                    <match serverVariable="RESPONSE_Cache-Control" pattern="(.*)" />
                    <conditions>
                    </conditions>
                    <action type="Rewrite" value="no-cache" />
                </rule>
                <preConditions>
                    <preCondition name="IsHTML">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
    
Please Sign in or register to post replies

Write your reply to:

Draft