1

I have a CloudFront distribution with orign S3. The Bucket (versioning disabled) contains images.

Behaviour of the connection between CloudFront and S3:

  • Redirect HTTP to HTTPS
  • Cached options:GET, HEAD (Cached by default) & OPTIONS
  • Cache Based on Selected Request Headers (None)
  • Use Origin Cache Headers
  • Min TTL: 0
  • Default TTL: 86400
  • Max TTL: 31536000
  • Forwad cookies: all
  • Query string forwarding: forward all based on cache
  • restrict viewer access, streaming, compress: no

My images in S3 have the following metadata (no cache control headers):

Content-Type image/jpeg
x-amz-meta-md5 lYw9zHZxxxxxxx8468A==

Now we have uploaded a new image in S3 around 5 days ago. When we open the image in S3 or download it we see the new image.

Now in CloudFront we are still seeing the old image while we were expecting a cache refresh after 24 hours.

By default, CloudFront caches a response from Amazon S3 for 24 hours (Default TTL of 86,400 seconds).

When I curl the image 2 times:

HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 12769
Connection: keep-alive
Date: Tue, 22 Oct 2019 08:57:57 GMT
Last-Modified: Thu, 18 Oct 2018 10:00:56 GMT
ETag: "0d581eef776ab0b6d44dd27c8759714a"
x-amz-meta-md5: DVge73dqxxxdJ8h1lxSg==
Accept-Ranges: bytes
Server: AmazonS3
X-Cache: Miss from cloudfront

HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 12769
Connection: keep-alive
Date: Tue, 22 Oct 2019 08:57:57 GMT
Last-Modified: Thu, 18 Oct 2018 10:00:56 GMT
ETag: "0d581eef776ab0b6d44dd27c8759714a"
x-amz-meta-md5: DVge73dqxxxdJ8h1lxSg==
Accept-Ranges: bytes
Server: AmazonS3
X-Cache: Hit from cloudfront

First a miss, then a hit, but the last modified date is still too long ago and the new image is not retrieved from S3. I know I can create an invalidation but I don't want to make new invalidations every time we have new images available.

What could be the issue here? if you need more info, please ask!

DenCowboy
  • 10,114
  • 24
  • 80
  • 168
  • did you check: [AWS cloudfront not updating on update of files in S3](https://stackoverflow.com/questions/30154461/aws-cloudfront-not-updating-on-update-of-files-in-s3) – Sudhendu Oct 22 '19 at 09:32
  • I checked it, but we waited for many days (we do not expect the images to update on the same day) and we don't set headers or want to make invalidations – DenCowboy Oct 22 '19 at 09:39
  • 1
    The "X-Cache: Miss from cloudfront" indicates that the issue isn't with CloudFront's caching, as fetching from the origin still returns an unexpected file. What's your origin configuration? Does the request maybe go to another origin or to another object in S3? – Dunedan Oct 22 '19 at 11:10
  • @Dunedan thanks for the reply. We are using an Origin Access Identity to access the S3 bucket (just default origin of this CDN, there is no other origin). (no proxy or anything else in between). The bucket has tags but no versioning, not static, no encryption, no logging, nothing else). Public access is disabled (you can not visit the S3 url of an object, only download it or use cloudfront). Policy is configured so OAI can GetObject on bucket-name/*. No other configurations. – DenCowboy Oct 22 '19 at 12:46
  • I guess you also double checked that your not accidentally requesting a different object than the one your changed a few days back. In this case I'd suggest getting in contact with the AWS Support as this doesn't sound like it should behave. – Dunedan Oct 22 '19 at 12:51

0 Answers0