How to expire(remove) page caching in ASP.Net
June 7, 2010 at 4:25 pm 1 comment
Hey Folks,
Today I have faced one problem in my live website. It was showing old contents though I have changed the content in the web page. Then as I press F5 or Ctrl+F5 it will show me the right content. I have removed my cache from the browser but not succeed.
Then I have written below code in page level in Page_Load event, and then my page worked live never before. Here is the code:
VB:
‘Remove Page Caching…
Response.Expires = -1
Response.ExpiresAbsolute = Now()
Response.CacheControl = “no-cache”
C#:
//Remove Page Caching…
Response.Expires = -1;
Response.ExpiresAbsolute = DateTime.Now;
Response.CacheControl = “no-cache”;
Hurreeyyy !!!
Entry filed under: ASP.Net. Tags: .
1.
Samir Varteji | June 7, 2010 at 4:35 pm
Excellent Post !!
Keep up the good work
It is really help full..
Thanks,
Samir Varteji