Cache-Control Header & Browser Caching IIS7

compressioniis-7

I am using Google Page Speed on my website in IIS7 and I was wondering how to set

Leverage browser caching – The following resources are missing a cache expiration
Leverage proxy caching – Consider adding a "Cache-Control: public" header to the following resources.

I am using doDynamicCompression in my web.config and little confused how to set these ? Hoping for some help

Note: Reference being used http://www.iis.net/ConfigReference/system.webServer/httpCompression

Best Answer

Under system.webServer in web.config set for example

<caching>
            <profiles>
                <add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" location="Any" />
                <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" location="Any" />
                <add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" location="Any" />
            </profiles>
        </caching>

This can also be configured from IIS Manager under Output Caching but what the GUI doesn't do is set the 'location' attribute. Setting it to 'Any' will set Cache-Control:public.

You can read more about it here.