user150528
user150528

Reputation: 507

Overwrite web.config setting

Environment: IIS 7, .Net 4.0

In web.config of our application, it has this section:

<system.webServer>
  <httpProtocol>
   <customHeaders>
     <add name="cache-control" value="no-cache" />
   </customHeaders>
  </httpProtocol>
</system.webServer>

Most of our application requires no-cache, but there is only one page that requires cache-control to be Private. Is a way to do it?

Appreciated for any input

Upvotes: 0

Views: 2387

Answers (2)

Sandeep
Sandeep

Reputation: 399

You can also change response caching for a page by setting the location attribute of @outputcache directive.

<%@ OutputCache Location="Server" %>

Upvotes: 0

Waqas Raja
Waqas Raja

Reputation: 10872

You cannot apply or override settings from web.config to a particular page, however you can do this for all pages inside a folder, by following settings.

<system.webServer>
  <httpProtocol>
   <customHeaders>
     <remove name="cache-control" />
     <add name="cache-control" value="no-cache" />
   </customHeaders>
  </httpProtocol>
</system.webServer>

However, you can override the cache-control settings in Page_Load event of a particular page.

Response.CacheControl = "Private";

Upvotes: 1

Related Questions