Reputation: 561
I am serving static images from an S3 bucket and adding a header of Cache-Control: public,max-age=31557600
to all assets in the bucket. The assets are then distributed via cloudfront. Here are the headers in the browser:
Request URL: cloudfront url here
Request Method:GET
Status Code:304 Not Modified
Remote Address: remote address
Referrer Policy:no-referrer-when-downgrade
Response Headers
HTTP/1.1 304 Not Modified
Connection: keep-alive
Date: Fri, 25 Aug 2017 14:00:27 GMT
ETag: "871e4a2d65f891b79a30b1fdf7622650"
Server: AmazonS3
Age: 52182
X-Cache: Hit from cloudfront
Via: 1.1 f348970492a18bf5c630c5acc86c1ee3.cloudfront.net (CloudFront)
X-Amz-Cf-Id: u35A-l_zhEAMsJSmtLmf4VFIPfBfDLdBqIjdjwfAJSDBcJhxLC7OdA==
I am unsure about what to make out of this. I believe hit from cloudfront
means that the edge servers are caching my assets. Does this mean that CloudFront has obeyed the Cache-Control
headers being sent from S3, and these images are being cached in CloudFront edge servers? Or are the images being cached in the broswer? I appreciate any help with elucidating my confusion. Thanks!
Upvotes: 3
Views: 1736
Reputation: 3751
There are two headers to look at when determining if cloudfront is caching.
Based on those to headers, yes, cloudfront is caching your content as you asked by setting cache-control headers.
Upvotes: 4