Anabell CC
Anabell CC

Reputation: 39

How to add s-maxage to Web,Config Cache Profile

I would like to create multiple Cache Profiles in my Web.Config for different types of pages in my web application. For example, data forms do not change often so I would increase the Cache-Control max-age. And for other pages, more frequent requests to the proxy server or origin server will be made, so Cache-Control maxage and s-maxage values will be set differently.

I am able to set the max-age with no problem. But have difficulty looking for solutions on the internet over setting the s-maxage on the web.config.

<caching>
   <outputCacheSettings>
     <outputCacheProfiles>
       <add name="Cache1Hour" duration="30" varyByParam="none" />
     </outputCacheProfiles>
   </outputCacheSettings>
 </caching>

My last resort is to manually add maxage and s-maxage to the Action methods.

    Response.Cache.SetMaxAge(maxAge);
    Response.Cache.SetProxyMaxAge(proxyMaxAga);

Any advice on the best way to do this? Ideally, I would like to use an attribute to decorate my Action methods.

Upvotes: 1

Views: 235

Answers (0)

Related Questions