rack-reverse-proxy icon indicating copy to clipboard operation
rack-reverse-proxy copied to clipboard

ReverseProxy on Heroku with RackCache?

Open kbighorse opened this issue 12 years ago • 5 comments

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!

kbighorse avatar Sep 26 '12 04:09 kbighorse

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.

jaswope avatar Sep 26 '12 14:09 jaswope

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

kbighorse avatar Sep 26 '12 20:09 kbighorse

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.

peterwald avatar Oct 10 '12 14:10 peterwald

So maybe I should submit a patch to Rack::Cache? or submit a patch to send a string arg from ReverseProxy?

kbighorse avatar Oct 10 '12 19:10 kbighorse

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.

peterwald avatar Oct 10 '12 21:10 peterwald