C# – Logout – How to clear cache , asp.NET

asp.netcvisual studio 2010

I am working on an asp.NET 4.0 Web Application with C#. I am currently authentication with the use of sessions, and on logout I am clearing the session. However there is a problem when the user presses back, he is still able to see the cached page. I would like to disable caching, of such pages, or make sure that it is checked for.

What is the best way of doing this? If I set the server to not store cached information, will this effect all the applications or will it just be my application?

Best Answer

Add this in page_load

Response.Cache.SetCacheability(HttpCacheability.NoCache);

This is the only true answer although it's important to know that it's only a request to the browser to stop caching - it doesn't necessarily have to follow.

This needs to be included on every page you don't want the user to 'back button' onto.