Supporting ", " for Cache-Control max-age directives in ngx_http_upstream.c
Igor Sysoev
igor at sysoev.ru
Fri Feb 5 13:36:35 MSK 2010
On Fri, Feb 05, 2010 at 07:24:19PM +0900, Zev Blut wrote:
> Hello,
>
> I have started to experiment with the nginx proxy_cache settings.
> During my tests I have found that a simple Rails application that
> outputs Cache-Control headers is not recognized by nginx.
>
> Using the "expires_in(15.minutes, :public => true)" command in Rails
> will output something like this:
>
> Cache-Control: max-age=900, public
>
> I spent sometime trying to get this to work with nginx, but with no
> success. I dug in the source code for nginx-0.7.64's
> ngx_http_upstream.c and found that line 3018-3020 has this:
> "
> if (*p == ';' || *p == ' ') {
> break;
> }
> "
> I think nginx wants max-age to either be
> Cache-Control: max-age=900; public
> or
> Cache-Control: max-age=900 public
> or
> Cache-Control: max-age=900
>
>
> Looking at the #rule in
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2
> and the BNF definition for Cache-Control
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
>
> I think nginx should also allow ',' in the *p checks.
> Like so:
> " if (*p == ';' || *p == ' ' || *p == ',' ) {"
>
>
> For now, without changing nginx, I can manually create a Cache-Control
> response in Rails with ";" or " " and nginx properly caches the response.
>
> But, I think we should patch nginx to accept ','.
>
> BTW, proxy_cache is quite cool!
It has been already fixed in 0.8.20 and 0.7.65:
*) Bugfix: nginx did not treat a comma as separator in the
"Cache-Control" backend response header line.
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list