Live Chat Icon For mobile
Live Chat Icon

How can I remove the cache of a page (cached with VaryByParam) for certain request params in code

Platform: ASP.NET| Category: Output Caching

You can attach a cache dependency to the response that is unique per query param, then invalidate the dependency for that particular param:


// add cache item dependency on response 
string cacheKey = 'xxx.aspx?' + queryParam; 
Cache[cacheKey] = new object(); 
Response.AddCacheItemDependency(cacheKey); 

// invalidate the dependency 
string cacheKey = 'xxx.aspx?' + queryParam; 
Cache.Remove(cacheKey); 

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

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

Please submit your question and answer.