Search code examples
asp.netcachingoutputcachecache-control

ASP.NET System.Web.UI.Page Cache Key Dependencies, How to?


How do I setup caching for a Page in ASP.NET and give it a cache key dependency? I am familiar how to do this with a UserControl, I set a Partial Caching attribute and then set

this.CachePolicy = new CacheDependency(..)

How would I do this for a Page? It does not have a CachePolicy object, thanks.


Solution

  • Found the answer:

    private void Page_Load(object sender, System.EventArgs e) { Response.AddCacheItemDependency("Pages"); }

    where "Pages" is the cache key dependency.