Microsoft KB Archive/311006

= HOW TO: Prevent Web Caching in Windows 2000 =

Article ID: 311006

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft Windows 2000 Server

-



This article was previously published under Q311006



IN THIS TASK
SUMMARY
 * Enable Content Expiration in IIS 5.0
 * Prevent Caching Using an ASP Script

REFERENCES



SUMMARY
This step-by-step article describes how to prevent the Web caching of objects on your server.

back to the top

Enable Content Expiration in IIS 5.0
When content expiration is enabled, the Web browser compares the current date to the expiration date to determine whether to display a cached page or request an updated page from the server.

To set the expiration of Web site content in IIS 5.0, follow these steps:
 * 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.

back to the top

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:  Open the ASP file in the editor of your choice.  Add the following script to very top of the ASP file: <% Response.Expires = 0 Response.Expiresabsolute = Now - 1 Response.AddHeader &quot;pragma&quot;,&quot;no-cache&quot; Response.AddHeader &quot;cache-control&quot;,&quot;private&quot; Response.CacheControl = &quot;no-cache&quot; %>



back to the top

