clear cashe from web config

Hi Experts,
is there an option to clear the cashe form the web config of an application in asp.net?
shpresaAsked:
Who is Participating?
 
Bob LearnedCommented:
Disabling I have heard of, but not clearing...
0
 
Bob LearnedCommented:
I don't know of any way in the web.config file, but I do know of this:

foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache){
    HttpContext.Current.Cache.Remove(string(entry.Key));
}

Open in new window


ASP.NET 4.5

foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache){
    HttpContext.Current.Cache.Remove((string)entry.Key);
}

Open in new window

0
 
Miguel OzSoftware EngineerCommented:
If you need to disable the cache for the whole site, then please add OutputCache key as explained here.
        <caching>
            <outputCache enableOutputCache="false"/>            
        </caching>

Open in new window

0
 
shpresaAuthor Commented:
Hi Miguel Oz
where do you place the ??
 <caching>
            <outputCache enableOutputCache="false"/>            
        </caching>

web config?
0
 
Bob LearnedCommented:
That goes in the web.config file, under the <system.web> element:

<configuration>
    <system.web>
        <caching>
            <outputCacheSettings enableOutputCache="false"/>
        </caching>
    </system.web>
</configuration>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.