Caching not working

Hello,

I’m running nginx 1.0.15. I have the following in my http block:

proxy_cache_path /var/tmp/nginx/proxy/cache/quickgit levels=1:2
keys_zone=quickgit:200m;
proxy_temp_path /var/tmp/nginx/proxy/temp;

and in my server block I have (among some other things):

index index.php;

error_page 418 = @feed;

if ( $args ~ a=atom ) {
    return 418;
}
if ( $args ~ a=rss ) {
    return 418;
}

location @feed {
    include /etc/nginx/fastcgi_params;

    proxy_cache quickgit;
    proxy_hide_header Set-Cookie;
    proxy_cache_key "$scheme$host$request_uri";
    proxy_cache_use_stale error timeout invalid_header updating;
    proxy_cache_valid 200 302 10m;
    proxy_cache_valid 404 1m;
    proxy_cache_valid any 1m;
    proxy_ignore_headers X-Accel-Redirect X-Accel-Expires Expires

Cache-Control Set-Cookie;

    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME 

$document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
}

I know that the @feed location is being hit at the appropriate time
because if I put a “return 404” in there I get a 404 page when accessing
the atom/rss URLs. Additionally, nginx creates the correct directories
under /var/tmp/nginx/proxy. However, nothing shows up in the
cache…I’ve tried tweaking all sorts of parameters (including the
proxy_ignore_headers, even though I only see Set-Cookie coming from the
backend) but nothing has helped.

Thanks in advance,
Jeff

Hello!

On Mon, May 14, 2012 at 09:24:06PM -0400, Jeff M. wrote:

[…]

    proxy_cache quickgit;

[…]

    fastcgi_pass 127.0.0.1:9000;

[…]

under /var/tmp/nginx/proxy. However, nothing shows up in the
cache…I’ve tried tweaking all sorts of parameters (including the
proxy_ignore_headers, even though I only see Set-Cookie coming from the
backend) but nothing has helped.

To cache fastcgi responses got via fastcgi_pass you have to use
fastcgi_cache, not proxy_cache.

Maxim D.

On 5/15/2012 5:39 AM, Maxim D. wrote:

Hello!

Hi! :slight_smile:

under /var/tmp/nginx/proxy. However, nothing shows up in the
cache…I’ve tried tweaking all sorts of parameters (including the
proxy_ignore_headers, even though I only see Set-Cookie coming from the
backend) but nothing has helped.

To cache fastcgi responses got via fastcgi_pass you have to use
fastcgi_cache, not proxy_cache.

Ugh. Complete and utter PEBKAC.

Thanks a bunch, it works now.

–Jeff