5

I have a page that has controls that are output caches (partial output caching). These are setup like this:

[PartialCaching(86400, null, null, "campaign.whatwhere", true)]
public partial class controls_LatestEnquiriesListCached : System.Web.UI.UserControl
{

...

With

public override string GetVaryByCustomString(HttpContext context, string custom)
{
    if (custom == "campaign.whatwhere")
    {
        return (CampaignManager.CurrentCampaign.DefaultWorkTypeId ?? 0).ToString() + (CampaignManager.CurrentCampaign.DefaultEnquiryAreaId ?? 0).ToString();
    }
    return base.GetVaryByCustomString(context, custom);
}

In Global.asax

How can I setup so I can clear this output cache on a specific page?

Is it possible to setup like MyPageWithCachedControl.aspx?ClearCache=true???

Micha
  • 5,117
  • 8
  • 34
  • 47
Niels Bosma
  • 11,758
  • 29
  • 89
  • 148
  • Exact duplicate of http://stackoverflow.com/questions/565239/any-way-to-clear-flush-remove-outputcache – Ramesh Mar 26 '12 at 12:34
  • Also http://stackoverflow.com/questions/37101/how-to-clear-outputcache-for-website-without-restarting-app – Ramesh Mar 26 '12 at 12:34
  • How are these exact duplicates? – Niels Bosma Mar 27 '12 at 15:30
  • You should use HttpResponse.RemoveOutputCacheItem(path) to clear the output cache where path is the virtual absolute path of the user control as specified in the http://stackoverflow.com/a/37167/30594 – Ramesh Mar 28 '12 at 03:51

3 Answers3

0

Use HTTPResponse.RemoveOutputCacheItem(pathofpage) to clear the cache of a particular page.

For example:

private void Button1_Click(object sender, System.EventArgs e)
{
   HttpResponse.RemoveOutputCacheItem("/form1.aspx");
}
Dave Hogan
  • 3,201
  • 6
  • 29
  • 54
0

You can create an aspx page that does nothing but clears cache. You can take the querystring parameter and have it delete by cache key.

Or you can try to find and ASP.NET cache manager.

Danny G
  • 3,660
  • 4
  • 38
  • 50
0

You should use HttpResponse.RemoveOutputCacheItem(path) to clear the output cache where path is the virtual absolute path of the user control as specified in the https://stackoverflow.com/a/37167/30594

Community
  • 1
  • 1
Ramesh
  • 13,043
  • 3
  • 52
  • 88