ASP.NET: Disable browser and proxy caching for aspx resources

The following lines of code can be put into a .aspx file to prevent the resource from being cached on clients or proxies:


To prevent caching, these lines of code change the header of the server’s HTTP response by setting the following values:

  • Cache-Control: no-cache, no-store
  • Expires: -1
  • Pragma: no-cache

You can read more about other possible caching options that can be passed to SetCacheability() here.


Leave a Reply

Your email address will not be published. Required fields are marked *