Query about setting max-age and ignoring files
JasonNewton1 opened this issue · 13 comments
I wanted to quickly ask you question about the S3_website.yml file and it's configuration.
Specifically, which line do I need to alter so that my styles. css file has a very long expiration date?
Whenever I run the .yml file on my s3 bucket, it sets my css to 86400 seconds (one day). This is the default TTL on my distribution (which obviously I do not wish to alter) - I just want to always make sure my css is set far into the future whenever I run s3_website. Is there a way to ignore the CSS object when I push my update?
Can I just do this?
ignore on server:
- styles.css
- .*jpg
Will the following setting solve your problem?
cache_control:
"styles.css": public, max-age=31104000
See https://github.com/laurilehmijoki/s3_website#max_age for details.
I'll try this and get back to you. Thanks for replying so quickly, I really appreciate it.
This doesn't seem to make a difference. When I go back into the S3 console and look at the object 'styles.css'), the meta data has been set back to 'Cache-Control max-age=86400'
I've attached my yml file (minus AWS credentials), if it's possible would you be able to take a brief look at it?
Kind Regards
Do you have both max_age
and cache_control
? If yes, try removing the max_age
setting. These two settings are mutually exclusive.
Okay, just one moment.
I removed the line:
"css/*": <%= 60 * 60 * 24 * 365 %>
but it hasn't made a difference. The css file still has the same value of 86400.
Kind Regards
Try removing the "*": <%= 60 * 60 * 24 %>
setting in your max_age
config.
I removed that line but my CSS file still has 'Cache-Control max-age=86400' on the S3 console.
Do you still have that ignore_on_server
setting? If yes, try removing it.
yes, I do.
I also have this now:
max_age:
"css/*": <%= 60 * 60 * 24 * 365 %>
"fonts/*": <%= 60 * 60 * 24 * 365 %>
"images/*": <%= 60 * 60 * 24 * 365 %>
I removed the ignore_on_server
and it seems to have fixed it.
Thanks again.
👍