Thursday, October 12, 2006

Preventing page caching and displaying “Page has expired” in ASP.NET 2.0

I have found two answers to this question:

Response.Buffer = True
Response.ExpiresAbsolute = Now().Subtract(New TimeSpan(1, 0, 0, 0))
Response.Expires = 0
Response.CacheControl = "no-cache"

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

Note that Response.Expires is deprecated in ASP.NET and Response.Cache.SetExpires should be used instead.

<%@ OutputCache location="none" %>

Source: http://www.syncfusion.com/FAQ/aspnet/WEB_c25c.aspx

More details at http://www.c-sharpcorner.com/asp/Articles/CachingInASPDPL.asp

No comments: