Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable cache globally .NET

Tags:

.net

caching

is there a way to disable server caching globally in ASP.NET? Like by adding some sort of setting to the web.config file?

So far I've tried adding these and it didnt make a difference...

        <caching>
          <sqlCacheDependency enabled="false"></sqlCacheDependency>
            <outputCache enableOutputCache="false"
                enableFragmentCache="false"
                sendCacheControlHeader="false"
                omitVaryStar="false" />
        </caching>
like image 695
user441365 Avatar asked Apr 05 '11 10:04

user441365


People also ask

How do I disable API cache?

Just use the Cache-Control: no-cache header. Implement it as delegating-Handler and make sure your header is applied (with MS Owin Implementation hook up on OnSendingHeaders() .

How do I disable cache in web config?

If you want to disable caching of all files in a folder and its subfolders you can add a Web. config in the root folder you want to disable browser caching for. Say you wanted to disable browser caching for the files in the folder js/nocache and all subfolders, then you would place the Web. config here: js/nocache/Web.

What is ResponseCache?

Response caching reduces the number of requests a client or proxy makes to a web server. Response caching also reduces the amount of work the web server performs to generate a response. Response caching is controlled by headers that specify how you want client, proxy, and middleware to cache responses.


1 Answers

There is also a way of disabling this in system.webServer if you are using IIS7/7.5 or IIS Express. This will work in your main web.config file (for both webforms and mvc) and also in web.config files in subfolders, to disable it for particular areas of your application.

<system.webServer>
    <caching enabled="false" />
</system.webServer>
like image 133
Stuntbeaver Avatar answered Sep 21 '22 20:09

Stuntbeaver