Live Chat Icon For mobile
Live Chat Icon

How can I set a page/control to be cached only for certain parameters

Platform: ASP.NET| Category: Output Caching

Let’s say you set your output cache directive as follows:

<%@ OutputCache Duration='86400' VaryByParam='RegionID' VaryByCustom='ProductID' %>

VaryByCustom – is a string that your application has to interpret in the GetVaryByCustomString override in the gloabal.asax file.

Now, to avoid caching pages for certain ProductIDs you can set the cacheability to private or nocache from your page load for those pages as follows:




Response.Cache.SetCacheability(HttpCacheability.Private) ;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.