How to set content expiration for your IIS7 site

Do you want to assure that client browsers will always download the latest copy of your page(s) rather than potentially pulling an outdated page from their local cache? You can enable and manage content expiration in IIS7 to control this at the server-side. Below is a walk-through of enabling this using the IIS7 Remote Management Services.

You access the setting from the IIS management console: Select the HTTP Response Headers module:

Then on the right-hand side of the console click the Add Common Headers link:

The dialog box that shows next has an Expire Web Content checkbox:

From there you can select to have the content expire immediately if you don't want the browser to cache anything at all; or to expire after a certain period of time (certain number of minutes, hours, days, etc.); or set it to expire on a certain specific date:

OrcsWeb's managed hosting plans and Cytanium's discount shared hosting plans all support IIS7 Remote Management Services. If you aren't sure if your host supports this, just ask them. If they don't you can still manage these settings through the web.config file.

Here's a quick sample for turning off client caching for your .Net site:

<configuration>
   <system.webServer>
      <staticContent>
         <clientCache cacheControlMode="DisableCache" />
      </staticContent>
   </system.webServer>
</configuration>

Note that some hosts may have this feature locked down. If you encounter any issues just touch base with the host to confirm they support this.

Happy hosting! 

No Comments