rack-reverse-proxy
rack-reverse-proxy copied to clipboard
ReverseProxy on Heroku with RackCache?
Here's my config in config/production.rb:
https://gist.github.com/3786109
Heroku logs output:
https://gist.github.com/3786102
Went off this blog post:
http://bindle.me/blog/index.php/304/rack-middleware-for-seo-fun-and-profit
I realize I didn't use the RegEx, but I got a similar result when I did.
thank you!
Hrmm, I don't see anything in there that signifies that this is a problem with rack-reverse-proxy. It looks like Rack::Cache is choking on a cache-control header, but I'm not sure where to point you for that.
OK, that might be true, but I also have a problem when I try in development, here's my output:
https://gist.github.com/3790532
Here's my config/development.rb:
https://gist.github.com/3790540
Turns out that all of the header values sent through reverse_proxy are wrapped in an array rather than a plain string. This breaks Rack::Cache further up the line.
{
"content-type"=>["text/html; charset=UTF-8"],
"connection"=>["keep-alive"],
"keep-alive"=>["timeout=20"],
"x-ua-compatible"=>["IE=Edge,chrome=1"],
"x-cacheable"=>["SHORT"],
"vary"=>["Accept-Encoding,Cookie"],
"cache-control"=>["max-age=600, must-revalidate"],
"x-cache"=>["HIT: 1"],
"x-cache-group"=>["normal"],
"x-type"=>["default"]
}
Rack::Cache is expecting the Cache-Control header to be "cache-control" => "max-age=600, must-revalidate" instead.
So maybe I should submit a patch to Rack::Cache? or submit a patch to send a string arg from ReverseProxy?
I submitted a pull request with my patch that fixes the issue for me. https://github.com/jaswope/rack-reverse-proxy/pull/25
AFAIK, the Rack interface expects headers to be strings. Returning them as an array is not expected.