# Caching not working

**URL:** <https://www.ruby-forum.com/t/caching-not-working/219749>\
**Category:** NGINX\
**Created:** [May 15, 2012, 3:24am UTC](https://www.ruby-forum.com/t/caching-not-working/219749 "2012-05-15T03:24:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [May 15, 2012, 3:24am UTC](https://www.ruby-forum.com/t/caching-not-working/219749/1 "2012-05-15T03:24:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [May 15, 2012, 11:39am UTC](https://www.ruby-forum.com/t/caching-not-working/219749/2 "2012-05-15T11:39:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [May 15, 2012, 8:09pm UTC](https://www.ruby-forum.com/t/caching-not-working/219749/3 "2012-05-15T20:09:01Z")

</div>

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

> Hello!

Hi! 🙂

> > 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
