Supporting ", " for Cache-Control max-age directives in ngx_http_upstream.c

Zev Blut zblut at
Fri Feb 5 13:24:19 MSK 2010


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 == ' ') {
I think nginx wants max-age to either be
Cache-Control: max-age=900; public
Cache-Control: max-age=900 public
Cache-Control: max-age=900

Looking at the #rule in
and the BNF definition for Cache-Control

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!


More information about the nginx mailing list