…meie igapäevast IT’d anna meile igapäev…


Clear ASP.NET application cache

Filed under: Nipid,Programmeerimine — Sander @ 16:46:59

From time to time I’ve needed a way to clear ASP.NET cache – you know, the views cached with <%@ OutputCache Duration="3600" VaryByParam="None" %>. Usually the reason has been that changes in the development server needed to be shown while the caching is still “on”.

I used to do this with a change to web.config (add extra line, undo, save – the file is changed, cache is invalidated), but I wanted something that wouldn’t require me to access the test server every time.

if (!string.IsNullOrEmpty(HttpContext.Request.Params["emptycache"]))


    foreach (DictionaryEntry entry in HttpContext.Cache)





Add that snippet to appropriate page/class (for me, HomeController’s Index() method, as I use ASP.NET MVC) – and whenever your URL has ?emptycache=1 in it, application cache is cleared. As simple as that.


1 kommentaar »

  1. Otsin ASP programmeerijat.
    Kui keegi oskab aidata: kaspar.fi@gmail.com

    Kommentaar kirjutas Kaspar — 2011-09-23 @ 15:50:13 | Vasta

RSS feed for comments on this post. TrackBack URI

Lisa kommentaar

Täida nõutavad väljad või kliki ikoonile, et sisse logida:

WordPress.com Logo

Sa kommenteerid kasutades oma WordPress.com kontot. Logi välja / Muuda )

Twitter picture

Sa kommenteerid kasutades oma Twitter kontot. Logi välja / Muuda )

Facebook photo

Sa kommenteerid kasutades oma Facebook kontot. Logi välja / Muuda )

Google+ photo

Sa kommenteerid kasutades oma Google+ kontot. Logi välja / Muuda )

Connecting to %s

Blog at WordPress.com.