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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
Method 2
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");
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0