Caching of Web Pages can happen in separate entities in a Web environment. When you think about caching, you usually think about the Web pages cached locally in your temporary Internet files on your local machine as a result of having visited the page. But caching can also occur within a proxy server if it is present. This article describes how to prevent client browser caching and proxy caching.
By default, the browser caches a visited Web page and stores it in the temporary Internet files of the profile that was used to log into the computer. If users of the browser do not want to be presented with cached pages when requested, they can define how the Internet browser will request content by following these steps:
For Internet Explorer 7.x
- Open Internet Explorer 7.x.
- From the Tools menu, click Internet Options.
- Click the General tab.
- Browsing history > Settings.
- Select "Every time I visit the webpage" for how often to check for newer versions of stored pages.
For FireFox 3.x.x
- Open FireFox 3.x.x.
- From the Tools menu, click Options.
- Click the Privacy tab.
- Uncheck "Keep my history for at least..."
But having all of your users do this is unreliable, and the above example describes only how to do this on one of many different browsers. To programmatically prevent a Web page from caching on the client, add the following line of code to the Meta section of your Web page:
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
Proxy Server Caching
To prevent the caching of Active Server Pages at the proxy server, add the following lines at the top of your .asp page:
<% Response.cachecontrol="private" %>
To Enable caching, add the following to your page:
<% Response.cachecontrol="public" %>