Rack::Cache incorrectly reporting a miss when query parameters are used

35 views
Skip to first unread message

DataShaman

unread,
Apr 12, 2009, 3:38:22 AM4/12/09
to rack-cache
Hi there,

I've setup a PHP installation which proxies requests from the browser
to a Sinatra application, hidden behind Rack::Cache.

The problem I'm encountering is when I use query parameters on the
requested URL.

The cache correctly sends a 304 as expected, but the log says 'miss'.
This only seems to happen when the original requested URL contains a
querystring.

Here's my PHP code:

$url = "http://example.org/sinatra/template.sass";
$method = 'HTTP_METH_'.$_SERVER['REQUEST_METHOD'];

$request = new HttpRequest($url, constant($method));

$request_headers = apache_request_headers();

// Remove Host header so as not to confuse Sinatra
unset($request_headers['Host']);

$request->setHeaders($request_headers);

if(!empty($_GET)) $request->setQueryData($_GET);

$request->setRawPostData(http_get_request_body());

$response_message = $request->send();

$response_message->send();

I've tried to pass as much info on to Rack::Cache as possible. The
Host header had to be removed.

Regards,
Marlin Forbes

DataShaman

unread,
Apr 12, 2009, 3:57:42 AM4/12/09
to rack-cache
Oh, and I've just put in a $request->enableCookies() which will copy
all incoming request cookies to the internal proxy request.

DataShaman

unread,
Apr 13, 2009, 1:15:49 AM4/13/09
to rack-cache
Hmmm, stranger and stranger - it's not the query string, one or more
of the propagated headers is causing the problem, I think.
Reply all
Reply to author
Forward
0 new messages