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

Is it possible to configure headers for assets to allow caching. #137

Closed
elorest opened this issue Mar 30, 2016 · 8 comments
Closed

Is it possible to configure headers for assets to allow caching. #137

elorest opened this issue Mar 30, 2016 · 8 comments

Comments

@elorest
Copy link

elorest commented Mar 30, 2016

No description provided.

@sdogruyol
Copy link
Member

For now there isn't anything like that for static files.

However you can do something like this

before_all do |env|
  env.response.headers.add "Cache-control", "public"
end

P.S: This will add cache for all.

@elorest
Copy link
Author

elorest commented Mar 30, 2016

Thanks. Would there be a way to do something like
before "/assets/*" do |env|

@ukd1
Copy link
Contributor

ukd1 commented Mar 31, 2016

@sdogruyol @isaacsloan if you have access to the env in the before_all you could match against the request uri?

@sdogruyol
Copy link
Member

@ukd1 @isaacsloan currently before filters does not work on anything other than routes.

@sdogruyol
Copy link
Member

Related issue crystal-lang/crystal#2470

@gottlike
Copy link

Only slightly related to this issue, but: Is there a way to set custom headers per route?

@sdogruyol
Copy link
Member

sdogruyol commented Apr 28, 2016

@gottlike sure something like this is possible.

get "/route1" do |env|
  env.response.headers.add "Some Header", "Some Value",
  "Response from 1"
end

get "/route2" do |env|
  env.response.headers.add "Another Header", "Another Value",
  "Response from 2"
end

@gottlike
Copy link

Cool, thanks for the quick reply!

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

4 participants