ASP.NET: How Do I: Cache an ASP.NET Page Based Upon Information in the HTTP Header

In this video Chris Pels shows how to keep a page in the ASP.NET output cache based upon information in the page’s HTTP header. First, the potential HTTP header values are reviewed. Then, a sample page is created and then the OutputCache directive is used with the VaryByHeader attribute which contains a value “accept-language”, an HTTP header, to control caching based upon the language of the user’s browser. The sample page is viewed in IE which is set to English and then in FireFox which is set to use French. Finally, the option to move the cache definition to a CacheProfile in the web.config file is discussed.