Welcome! Log In Create A New Profile

Advanced

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

Zev Blut
February 05, 2010 05:34AM
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!

Thanks,
Zev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

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

Zev Blut February 05, 2010 05:34AM

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

Igor Sysoev February 05, 2010 05:40AM

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

Zev Blut February 05, 2010 06:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 190
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready