Removing a Output Cache by Param.

vishalneeraj-24503
Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 1180
We can attach a cache dependency to the response that is unique per query param ,then invalidate the dependency for the particular param as:-

//Add cache item dependency on response object  
string cache_key = "rec_cv.aspx?" + query_param;
Cache[cache_key] = new object();
Response.AddCacheItemDependency(cache_key);

//invalidate the dependency
string cacheKey = "rec_cv.aspx?" + query_param;
Cache.Remove(cacheKey);

Comments or Responses

Login to post response