tags:

views:

42

answers:

2

Hi, I want to prevent my asp.net / c# 2008 web pages from being cached on the client side or the server side.

How can I go about doing that?

+1  A: 

For the client side you want to use the No-Cache

http://www.i18nguy.com/markup/metatags.html

Here is a link describing how to configure the response object for no caching on the server side:

http://www.extremeexperts.com/Net/FAQ/DisablingBackButton.aspx

Response.Buffer = True  
Response.ExpiresAbsolute = Now().Subtract(New TimeSpan(1, 0, 0, 0)) 
Response.Expires = 0 
Response.CacheControl = "no-cache"
Kevin
Though for the ExpiresAbsolute, I used Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
user279521
A: 

In your question, you specify no cache on both the client and server. To me this means no caching anywhere.

This will prevent any caching from happening anywhere.

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

Either put this in the load of the page(s) you don't want cached or create a base page class.

from http://skysanders.net/subtext/archive/2010/03/23/preventing-caching-of-content-in-asp.net-pages-and-other-httphandlers.aspx

Sky Sanders
you are correct, no caching anywhere.
user279521