Where is my max-age header coming from?

丶灬走出姿态 提交于 2019-12-23 21:35:30

问题


I'm well aware of how I could set it myself, but I am concerned about having it configured in two different places. To receive the bounty, please tell me where I should look to find the existing setting.

Places we've already looked for the existing setting, without success:

  • the web.config <StaticContent> section
  • IIS output caching section, at all three levels:
    • machine
    • site
    • application
  • Code (I did a global search for SetMaxAge)

Context

We recently noticed that our CSS and JS files aren't getting refreshed. When I inspect the network traffic, they are coming back from the server with a header (Cache-Control: max-age=604800) that gives them a seven-day lifespan.

We need to reduce the cache lifetime. But for the life of me I can't find where it is set.

It is not set in the web.config <StaticContent> section.

It is not set in the IIS output caching section (I looked under the machine, the site, and the application-- they are all blank).

It is not set in code-- I did a global code search for SetMaxAge and got nuthin'. Where else can I look?

Is it possible it is being set by the gateway or load balancer in our data center?


回答1:


You can do like this in web config, or you can use IIS ui to change (see link below):

<configuration>
  <system.webServer>
    <staticContent>
       <clientCache cacheControlMode="UseMaxAge"
        cacheControlMaxAge="1.00:00:00" /> <!-- 1 day -->
    </staticContent>
  </system.webServer>
</configuration>

See more here: https://www.iis.net/configreference/system.webserver/staticcontent/clientcache

IIS documentation states that the default value is 1 day.

Here are some other ways what could have affect these settings: http://www.galcho.com/blog/post/2008/02/27/IIS7-How-to-set-cache-control-for-static-content.aspx

  • overrideModeDefault value in applicationHost.config
  • earlier appcmd.exe settings
  • or client setting can also override your values.


来源:https://stackoverflow.com/questions/40499266/where-is-my-max-age-header-coming-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!