IIS 7.5 adds no-cache to cache-control response IIS 7.5 adds no-cache to cache-control response azure azure

IIS 7.5 adds no-cache to cache-control response


Apparently, the output cache needs a location attribute otherwise it will override the staticContent/clientCache setting.

<system.webServer>    ...    <caching>        <profiles>            <add extension="*" policy="CacheForTimePeriod" duration="00:01:00" varyByQueryString="*" varyByHeaders="X-Requested-With" location="Any" />        </profiles>    </caching>    ...</system.webServer>


Based on your problem I think you are using Windows Azure Cloud Services with a web role.

In that case you need to use Startup task to setup Cache-Control in the IIS which will stay with your website configuration once the role is started. The Command in your Startup task should be as below per your above setting:

appcmd.exe set config "Default Web Site/folder" -section:system.webServer/staticContent -clientCache.cacheControlCustom:publicappcmd.exe set config "Default Web Site/folder" -section:system.webServer/staticContent -clientCache.cacheControlMode:UseMaxAgeappcmd.exe set config "Default Web Site/folder" -section:system.webServer/staticContent -clientCache.cacheControlMaxAge:"30.00:00:00"

If you want to know how to use appcmd in a startup task you can read this article.