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>
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() .
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With