Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting Headers for Cache Control #250

Closed
richlewis14 opened this issue Feb 20, 2014 · 3 comments
Closed

Setting Headers for Cache Control #250

richlewis14 opened this issue Feb 20, 2014 · 3 comments

Comments

@richlewis14
Copy link

I can see that after reading issue #223 that we can now set expiry dates and cache control for our assets, but i don't know if im being stupid here but where and how do i set this? Its not doing it automatically is it as when i check this in my S3 bucket there is nothing set.

In the config.rb file (within the gem) i can see attr_accessor :custom_headers.. I really would like to know the syntax for setting this up

Any clarification would be great as it would really help the performance of my app.

thank you for taking the time to read this

@richlewis14
Copy link
Author

So i have been going through the config.rb file again and can see that custom_headers accepts a hash, so i have tried this

config.custom_headers = { 'Cache-Control' => 'max-age=315576000', 'Expires' => 1.year.from_now.httpdate }

but when uploading my assets to my bucket the headers are still not set ?

@bdarfler
Copy link

I believe you need a hash from filename or filename regex to a hash of headers. For instance

{ '.*' => { cache_control: 'max-age=315576000', expires: 1.year.from_now.httpdate } }

I also think you should use the constants not the strings for key names.

@richlewis14
Copy link
Author

Thank you, that helps a lot and answers the question.I will close the issue now....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants