How do I turn of caching in the webbrowser?

Topics: faq
Coordinator
Jul 16, 2008 at 1:24 PM
Edited Jul 16, 2008 at 1:33 PM
Response.AddHeader("Cache-Control", "no-cache, must-revalidate");
Response.AddHeader("Expires", "Wed, 16 Jul 2008 13:00:00 GMT"); // must be a date in the past


Jul 3, 2010 at 11:41 AM

I am using V2.0 and created an instance of the Server class.

To set the headers, subscribe to the SendingResponse event of the Server class and write something like:

private static readonly StringHeader CacheControlHeader =
	new StringHeader(@"Cache-Control", @"no-cache, must-revalidate");
private static readonly DateHeader ExpiresHeader =
	new DateHeader(@"Expires", new DateTime(2001, 01, 01));
  
private static void _server_SendingResponse(object sender, RequestEventArgs e)
{
	e.Response.Add(CacheControlHeader);
	e.Response.Add(ExpiresHeader);
}

Maybe this helps someone in the future.