Click here to Skip to main content
14,692,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using IE8 to access my application. I have implemented below code to make sure my web pages are not cached.


When I validate/verify the HTTP response using fiddler tool, I do not see any expiration details (max-age or Expires) within my reponse. I see Cache-Control: private. How do I make sure that my pages are not being cached?
Zoltán Zörgő 15-Aug-13 9:26am
You should put this setting at the point after the actual response object is created. There is no "template" you can set up.
What technology are you using: Web Forms, MVC, Web Pages?
Vipul Mehta 15-Aug-13 10:17am
I have created an httpModule class and have implemented this code there. I am using Web Forms with ASP.Net 3.5.
Vipul Mehta 19-Aug-13 14:38pm
I have implemented below code within the BeginRequest application event within my custom HttpModule class and registered it within the config file. But still within my response header, I see Cache-Control:private.

I am using IE8 and Fiddler web debug tool to monitor my responses.

public class AddCustomHeaderModule : IHttpModule
public void Init(HttpApplication context)
context.BeginRequest += new EventHandler(context_BeginRequest);

void context_BeginRequest(object sender, EventArgs e)
if (HttpContext.Current.Response != null)
HttpContext.Current.Response.AppendHeader("Cache-Control", "no-store, no-cache, must-revalidate");
HttpContext.Current.Response.AppendHeader("Pragma", "no-cache");
HttpContext.Current.Response.AppendHeader("Expires", "0");

<add name="AddCustomHeaderModule" type="Namespace.AddCustomHeaderModule">

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900