The cacheability of a page or user control refers to whether a page can be cached on a device during the page's response life cycle. Devices that can cache a page include the browser making the request, the Web server responding to the request, and any cache-capable devices, such as proxy servers, that are in the request or response stream.
You can set cacheability programmatically if your application will determine cacheability based on run-time conditions, such as reading the request header. For more information, see Setting the Cacheability of a Page.
To set a page's cacheability programmatically
In the page's code, call the method on the property of the object.
The following code sets the Cache-Control HTTP header to .
C#В Copy Code
If you pass either or to the SetCacheability method to prevent a requesting browser from caching a page in its History folder, any time a user clicks a back or forward button, a new version of the response will be requested. You can override this behavior conditionally by calling the method on the property and passing true for the allow parameter.
If you set cacheability to any value other than NoCache or ServerAndNoCache, ASP.NET ignores the value set by the SetAllowResponseInBrowserHistory method.