Cacheability

It could be sometimes usefull to prevent some web pages from being cached by the web browser
so that when you use the back button of the browser you get the latest output from the server and not a cached one. Now we are going to see the main actions necessary for performing this task.

In order to improve performance and because the experience has proven it's utility : web browsers generaly keeps cache of web pages they visit.

If we nedd to stop such behavior here the way:

Response.Cache.SetCacheability (HttpCacheability.NoCache);
Response.Cache.SetAllowResponseInBrowserHistory(false);

You may add these lines in the Page.Load event handler to see immediately the result.
The firts method controls how documents are cached on the cache capable device by setting the Cache-Control HTTP header.

"The second method SetAllowResponseInBrowserHistory indicates whether the response will be kept in browser History. Passing the value of false means the output will not be held in browser history"

This article has been very usefull for me so thank you Bipin Joshi from dotnetbips (http://www.dotnetbips.com/) for publishing it.

Comments

Popular posts from this blog