laurilehmijoki / s3_website

Manage an S3 website: sync, deliver via CloudFront, benefit from advanced S3 website features.
Other
2.24k stars 187 forks source link

cache_control and max_age, trying to configure globs properly #264

Closed BTCCoffeeTable closed 7 years ago

BTCCoffeeTable commented 7 years ago

Hello, great project, incredible work, thank you for your efforts.

My s3_website.yml:

s3_id: <%= ENV['S3_ACCESS_KEY_ID'] %>
s3_secret: <%= ENV['S3_SECRET_KEY'] %>
s3_bucket: MY_SITE.com

site: _site

index_document: index.html
error_document: 404.html

cache_control: public
max_age:
  "assets/*": 604800
  "*": 300

gzip:
  - .html
  - .css
  - .js

s3_reduced_redundancy: true

cloudfront_distribution_id: ID_GOES_HERE

cloudfront_distribution_config:
  default_cache_behavior:
    min_TTL: <%= 60 * 60 * 24 %>
  aliases:
    quantity: 1
    items:
      CNAME: MY_SITE.com

cloudfront_wildcard_invalidation: true

For some reason my cache_control headers are not getting piped thru. When I run page speed insights it says all of my assets have no headers. And when I do chrome dev tools I see:

cache-control: public

My understanding is that per my config it should be adding the max-age property, but it's not. Is this in part due to my cloudfront_distribution_config or maybe some silly error in the cache_control or max_age globs?

Thank you.

laurilehmijoki commented 7 years ago

Hello. The cache_control setting seems to override the max_age setting. They are not designed to work together, I think. What happens if you remove the cache_control setting?

BTCCoffeeTable commented 7 years ago

@laurilehmijoki

That was it, thank you so much. Fantastic implementation overall, keep up the good work. I really appreciate your swift response which fixed my issue perfectly. Thank you.

BTCCoffeeTable commented 7 years ago

@laurilehmijoki