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!
Great article! I was wondering how to do this recently.
Thanks.
Since you are familiar with IIS7 Web Site administration, I was wondering if you could help me out.
Our Team is building a C# project with a Silverlight module. We deploy to a Windows 2008 with IIS 7. I’m trying to Programmatically Expire the HTTP Response Headers Associated with a Folder called ClientBin immediately. I know how to do it manually through IIS Manager. ( Basically, I go to the HTTP Response Headers Section of the folder or file that is of interest, and then I use “Set Common Headers….” to expire immediately.) However, we will be Redeploying to IIS a number of times, and I want to ensure that it is programmatically done because it’s a headache to keep Reconfiguring all the time.
Should I do it from the C# code of my project or is it better practice to do it using WMI scripting and/or PowerShell?
Could someone please assist?
Thanks,
Web Developer
Sorry, but I’m not sure. Perhaps a site visitor will know and comment.