Blogger :
MSDN Blogs
All posts :
All posts by MSDN Blogs
Category :
SAPscript
Blogged date : 2006 Dec 23
Here are the list of knowledge base articles which explains how to prevent caching of the web pages from the server side.
IIS: How to Disable Caching of Specific MIME Types
HOW TO: Prevent Web Caching in Windows 2000
"Pragma: No-cache" Tag May Not Prevent Page from Being Cached
How to Use Pragma: No-cache with IIS and IE
How to Modify the Cache-Control HTTP Header When You Use IIS
Setting the IIS Object Cache Time Period
Few more articles which talks about avoiding caching on the ISA server which stands between the client and the web server and also on the client (IE).
How to prevent the caching of content from certain Web sites in Internet Security and Acceleration (ISA) Server 2006 or in ISA Server 2004
How to prevent caching in Internet Explorer
Here is the quick list of the steps you need to perform to prevent caching in IIS:
1. In the Internet Information Services snap-in, select the Web site, virtual directory, directory, or file for which you want to set content expiration.
2. Right-click the Web site, virtual directory, directory, or file and select Properties.
3. On the HTTP Headers property sheet, select Enable Content Expiration.
4. Select Expire Immediately, Expire after, or Expire on and enter the appropriate expiration information in the corresponding box.
NOTE: Typically, time-sensitive information is limited to individual files, directories, or Web sites; however, you can also set content expiration for all Web sites on a computer through the configuration of WWW Master Properties.
Prevent Caching Using an ASP Script
You can also prevent individual pages from being cached by adding a script to ASP files. To do this, follow these steps:
1. Open the ASP file in the editor of your choice.
2. Add the following script to very top of the ASP file:
<%
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
%>
Alternatively, if you want to prevent caching only for files with text content (eg. HTML, ASP) and not for image files such as .JPG, .GIF, it will be a better idea to move all the images or other file formats to a different folder and you can set individual caching properties for those folders in IIS or following the 1st article mentioned in this mail to prevent caching of specific MIME types.