2

We are using CloudFront as a CDN. The majority of our objects are caching correctly. For example,

https://static-d8.raystedman.org/theme/css/font-lato.css

This returns a Hit from CloudFront as you would expect.

We found that other objects always result in a "Miss from cloudfront" -- even with multiple requests to ensure the cache is loaded. For example,

[rsm@ray08 ~]$ h https://static-d8.raystedman.org/sites/default/files/css/css_U0-kHZ4VMcN4EKChPMkCrxU_94TFasPMQsBz33LXPAc.css
Array
(
    [0] => HTTP/1.1 200 OK
    [Content-Type] => text/css
    [Content-Length] => 212893
    [Connection] => close
    [Server] => nginx
    [Date] => Mon, 20 Dec 2021 15:02:21 GMT
    [Last-Modified] => Thu, 25 Nov 2021 11:07:28 GMT
    [Cache-Control] => public, s-maxage=31104000, max-age=31104000
    [Expires] => Mon, 03 Jan 2022 15:02:21 GMT
    [ETag] => "619f6e70-33f9d"
    [X-Powered-By] => PleskLin
    [Access-Control-Allow-Origin] => *
    [Accept-Ranges] => bytes
    [Vary] => Accept-Encoding
    [X-Cache] => Miss from cloudfront
    [Via] => 1.1 7b00c3fd9220034414107b03e53b1b8f.cloudfront.net (CloudFront)
    [X-Amz-Cf-Pop] => SFO5-P2
    [X-Amz-Cf-Id] => 0Mu6SkFY50W5MxfeuzhO0a-hhbDgcQqpYVaRZoT0HbWwfJQ6L5e02Q==
)

This Miss results in CloudFront accessing the origin with (which is logged at the origin):

[rsm@ray08 ~]$ h https://static-d8-origin.raystedman.org/sites/default/files/css/css_U0-kHZ4VMcN4EKChPMkCrxU_94TFasPMQsBz33LXPAc.css
Array
(
    [0] => HTTP/1.1 200 OK
    [Server] => nginx
    [Date] => Mon, 20 Dec 2021 15:09:31 GMT
    [Content-Type] => text/css
    [Content-Length] => 212893
    [Last-Modified] => Thu, 25 Nov 2021 11:07:28 GMT
    [Connection] => close
    [Cache-Control] => public, s-maxage=31104000, max-age=31104000
    [Expires] => Mon, 03 Jan 2022 15:09:31 GMT
    [ETag] => "619f6e70-33f9d"
    [X-Powered-By] => PleskLin
    [Access-Control-Allow-Origin] => *
    [Accept-Ranges] => bytes
)

The Behaviors for these two objects are setup the same way in the Distribution. How can I figure out why the second object is always a CloudFront Miss?

3
  • I think this was fixed when I got to testing it https://static-d8.raystedman.org/sites/default/files/css/css_U0-kHZ4VMcN4EKChPMkCrxU_94TFasPMQsBz33LXPAc.css shows x-cache: Miss from cloudfront for the first request then x-cache: Hit from cloudfront for the second. Dec 20, 2021 at 16:14
  • I see a duplicated header in the response. I don't think it is related, but something is incorrectly adding the header twice: access-control-allow-origin: * Dec 20, 2021 at 16:14
  • The duplicate header was caused by Apache and Nginx both adding the access-control-allow-origin header. This is now corrected. Thanks
    – Greg Sims
    Dec 21, 2021 at 0:42

1 Answer 1

2

I made a setting change the the Distribution "TLSv1.2_2021 (recommended)" which caused the Distribution to redeploy. Now we receive a CloudFront Hit for the second object as expected. I do not believe the TLS level made any difference. It is likely the redeploy of the Distribution resolved this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.