11

Is there a way clear or reset the outputcache for an entire website without a restart?

I'm just starting to use outputcache on a site and when I make a mistake in setting it up I need a page I can browse to that will reset it.

Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
Brian Boatright
  • 36,294
  • 34
  • 81
  • 102

2 Answers2

9

This should do the trick:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

 Dim path As String
 path="/AbosoluteVirtualPath/OutputCached.aspx"
 HttpResponse.RemoveOutputCacheItem(path)

End Sub
Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114
Ethan Gunderson
  • 10,959
  • 8
  • 30
  • 29
  • 5
    This answer does not in fact clear the cache for the "entire web site" as specified in original question. – Tim Booker Feb 17 '14 at 10:09
0

Add the following code to controller or to page code:

HttpContext.Cache.Insert("Page", 1);
Response.AddCacheItemDependency("Page");

To clear output cachne use the following command in controller:

    HttpContext.Cache.Remove("Page");
Andrus
  • 26,339
  • 60
  • 204
  • 378