Amazon Cloudfront Cache-Control: no-cache header has no effect after 24 hours

后端 未结 2 1501
猫巷女王i
猫巷女王i 2021-01-30 17:04

I\'m hosting a static website in S3 and using Cloudfront to cache files. I\'ve essentially got 3 files with the following headers:

  • index.html (Cache-Control: no-ca
2条回答
  •  自闭症患者
    2021-01-30 18:00

    Verify that the CloudFront distribution's Minimum TTL is set to 0. If it's set to any other value, CloudFront won't respect the no-cache header and will still cache the file for the Minimum TTL. More details about the caching directives can be found here:

    http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html

    If this doesn't help, try to debug the actual HTTP request for index.html and post the response headers here so we can have a look at them.

    Also, instead of using no-cache for the index.html file, you can try using

    public, must-revalidate, proxy-revalidate, max-age=0

    This will allow CloudFront to store the file on the edge location, but it will force it to revalidate it with the origin with each request. If the file hasn't changed, CloudFront will not need to transfer the file's entire content from the origin. This can speed up the response time, especially for larger files.

提交回复
热议问题