Max value for cache control header in HTTP

前端 未结 3 1561
天涯浪人
天涯浪人 2020-12-07 19:55

I\'m using Amazon S3 to serve static assets for my website. I want to have browsers cache these assets for as long as possible. What meta-data headers should I include with

3条回答
  •  隐瞒了意图╮
    2020-12-07 20:27

    Generally one year is advised as a standard max value. See RFC 2616:

    To mark a response as "never expires," an origin server sends an Expires date approximately one year from the time the response is sent. HTTP/1.1 servers SHOULD NOT send Expires dates more than one year in the future.

    Although that applies to the older expires standard, it makes sense to apply to cache-control too in the absence of any explicit standards guidance. It's as long as you should generally need anyway and picking any arbitrarily longer value could break some user-agents. So:

    Cache-Control: max-age=31536000
    

提交回复
热议问题