Hello there,

Is there any way of disabling caching of asp.net pages in folder or application level.... meant to say, is there any option available in the web.config file for disabling caching...i have done by using page wise...but need to disable caching for all pages in my application...

plz help me on how to disable caching for all asp.net pages at a time...

thanks for any help provided.

regards
shouvik

Dani AI

Generated

Short answer: yes — do it from web.config (or folder-level web.config) and, if needed, from IIS settings. That is more reliable than changing every page or relying on a BasePage/global.asax hack.

A simple, application-wide way to stop ASP.NET page output caching is to turn off the OutputCache at the app level (put this in the root web.config). This prevents ASP.NET's output-cache module from caching pages or honoring @OutputCache directives:

<configuration>
  <system.web>
    <caching>
      <outputCache enableOutputCache="false" enableFragmentCache="false" />
    </caching>
  </system.web>
</configuration>

See the OutputCache configuration/property documentation for details. (learn.microsoft.com)

Static files and IIS-level output caching are separate. To stop browsers caching static files in a particular folder, add a folder-level web.config with a clientCache setting; to turn off the IIS output cache entirely use the caching element:

<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMode="DisableCache" />
    </staticContent>
  </system.webServer>
</configuration>
<configuration>
  <system.webServer>
    <caching enabled="false" />
  </system.webServer>
</configuration>

These control client (browser) cache headers and IIS output-cache behavior respectively. (learn.microsoft.com)

Notes and troubleshooting: 's BasePage approach works but is less complete — it only affects pages that inherit the base class and runs inside ASP.NET; it won't change how IIS serves static files or how a proxy/CDN caches content. Global.asax BeginRequest header-setting also works for dynamic responses but is not a substitute for the two web.config/IIS controls above. After you apply changes, recycle the app pool (or touch web.config), then verify in the browser DevTools Network tab that responses show the Cache-Control/Expires/Pragma headers you expect. (learn.microsoft.com)

Recommended Answers

All 5 Replies

Response.Buffer=<SPAN style="COLOR: blue">true;<o:p></o:p>
Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = "no-cache";
Response.Buffer=<SPAN style="COLOR: blue">true;<o:p></o:p>
Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = "no-cache";

thanks for your quick reply...i know these...what i want is to disable caching in folder or application level...like using any settings in the web.config file or global.asax.file....somewhere i read this can be done using global.asax file but dnt know how to implement that....please help in this regards only.....

thnks once again...

I am not sure if there is way of disable caching using web.config file as this setting is more browser oriented.

I understand you want to just disable caching eveywhere by changing at one place. You can create a parent page and put the above code in the same and all the pages inherit from the same.

> is there any option available in the web.config file for disabling caching

Configure the OutputCacheSection. It is used to configure app-scope settings. Have a look at MSDN article - Cache Configuration in ASP.NET

> is there any option available in the web.config file for disabling caching

Configure the OutputCacheSection. It is used to configure app-scope settings. Have a look at MSDN article - Cache Configuration in ASP.NET

thnks for the link....though i have visited it earlier before posting the question but not found anything that can work for me....but now i have found something regarding outputcache section in the msdn article.....will try that thing out and will reply here as soon as i get any result...

in the mean time, thnks for all the info.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.