I am hosting a web app on Azure with the following Web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".text" mimeType="text/plain" />
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
This works but I would like to vary the cache age by extension. I would like to set the max age of .html files to 1 day and the max age of everything else to 365 days. The reason being that all of the assets in the html have their filenames revved on change and are served from a CDN, so they never need to expire, but the html pages themselves need to always be fresh so the user can see new content.
I see that the <location>
element allows filtering the Web.config to specific locations, but I don't see a way to limit it to certain extensions.
Please note that I don't require being able to do this in the Web.config: any means possible with an Azure Web App is fine.