IIS 7.5 How do you add a Dynamic HTTP Expires Header

前端 未结 2 1869
失恋的感觉
失恋的感觉 2020-12-12 07:20

In IIS 7.5, you can add static HTTP Response headers, but I want to add an \"Expires\" header that always specifies a date that is 7 days in the future.

I\'m running

相关标签:
2条回答
  • 2020-12-12 08:05

    You can only add dynamic expires header using program code.

    Source: The Microsoft IIS Site

    You should use Cache-Control max-age instead, like suggested in the other answer.

    0 讨论(0)
  • 2020-12-12 08:12

    This is a standard feature of IIS. The HTTP Response Headers module allows you to set this common header. This results in the following web.config:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <staticContent>
                <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
            </staticContent>
        </system.webServer>
    </configuration>
    

    You should do this only in the directories where you want this header to be send. Typically only directories with static content.

    0 讨论(0)
提交回复
热议问题