# Problem with fastcgi cache

**URL:** <https://www.ruby-forum.com/t/problem-with-fastcgi-cache/213315>\
**Category:** NGINX\
**Created:** [October 30, 2011, 4:55am UTC](https://www.ruby-forum.com/t/problem-with-fastcgi-cache/213315 "2011-10-30T04:55:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [October 30, 2011, 4:55am UTC](https://www.ruby-forum.com/t/problem-with-fastcgi-cache/213315/1 "2011-10-30T04:55:44Z")

</div>

Hello, I´m working with Nginx v1.0.8.

I have the configuration for fastcgi cache:

server {  
listen 8080;

```
    //many other lines of configuration

   fastcgi_cache_path /var/www/cache levels=1:2 keys_zone=zera:10m

```

inactive=5m;  
fastcgi\_temp\_path /var/www/cache/tmp;

```
  server {

```

listen 80;  
server\_name localhost;

```
    //more configuration

    location ~ "^(.+\.php)(/.+)" {
    set $script $uri;
    set $path_info "";

    error_log logs/debug.log debug;

    set $script $1;
    set $path_info $2;

    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_pass unix:/var/run/php.sock;
    fastcgi_cache zera;
    fastcgi_cache_key $server_addr$request_uri;

```

fastcgi\_cache\_valid 200 302 1h;  
fastcgi\_cache\_valid 301 1d;  
fastcgi\_cache\_valid any 1m;  
fastcgi\_cache\_min\_uses 1;  
fastcgi\_cache\_use\_stale error timeout invalid\_header http\_500;  
fastcgi\_index index.php;

```
    include fastcgi_params;

    fastcgi_param SCRIPT_FILENAME /var/www/myapp/web$script;
    fastcgi_param SCRIPT_NAME $script;
    fastcgi_param PATH_INFO $path_info;
}

```

I can´t see the nginx creating files in /var/www/cache or  
/var/www/cache/tmp.

The php process is actually doing the work.

Looking at the debug logs I can see:

2011/10/29 19:36:18 [debug] 32377#0: \*1 post access phase: 10  
2011/10/29 19:36:18 [debug] 32377#0: \*1 http init upstream, client  
timer: 0  
2011/10/29 19:36:18 [debug] 32377#0: \*1 epoll add event: fd:15 op:3  
ev:80000005  
2011/10/29 19:36:18 [debug] 32377#0: \*1 http script var:  
“10.128.50.101”  
2011/10/29 19:36:18 [debug] 32377#0: \*1 http script var:  
“/administration.php/school”  
2011/10/29 19:36:18 [debug] 32377#0: \*1 http cache key:  
“10.128.50.101/administration.php/school”  
2011/10/29 19:36:18 [debug] 32377#0: \*1 add cleanup: 092C6E3C  
2011/10/29 19:36:18 [debug] 32377#0: \*1 http file cache exists: -5 e:0  
2011/10/29 19:36:18 [debug] 32377#0: \*1 cache file:  
“/var/www/cache/8/4f/2de84a2a49161ae7d7d4d8fba314e4f8”  
2011/10/29 19:36:18 [debug] 32377#0: \*1 add cleanup: 092C6E80  
2011/10/29 19:36:18 [debug] 32377#0: \*1 http upstream cache: -5  
2011/10/29 19:36:18 [debug] 32377#0: \*1 http script copy:  
“QUERY\_STRING”

I preciate any help with this issue.

Thanks in advance.

Posted at Nginx Forum:

> **[Problem with fastcgi cache](https://forum.nginx.org/read.php?2,217538,217538#msg-217538)**
>
> Hello, I´m working with Nginx v1.0.8. I have the configuration for fastcgi cache: server { listen 8080; //many other lines of configuration fastcgi\_cache\_path /var/www/cache levels=1:2 keys\_zone=zera:10m inactive=5m;

---

<div class="post-metadata">

**Author:** ![firestorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c4cdca/32.png) [@firestorm](https://www.ruby-forum.com/u/firestorm)\
**Post date:** [November 1, 2011, 6:56pm UTC](https://www.ruby-forum.com/t/problem-with-fastcgi-cache/213315/2 "2011-11-01T18:56:27Z")

</div>

For more information my nginx server is installed in Ubuntu 10.04,  
compiled from sources the following compilation options:

./configure --user=www-data --group=www-data --with-http\_ssl\_module  
–with-http\_realip\_module --with-http\_addition\_module  
–with-http\_sub\_module --with-http\_dav\_module --with-http\_flv\_module  
–with-http\_gzip\_static\_module --with-http\_random\_index\_module  
–with-http\_secure\_link\_module --with-http\_stub\_status\_module  
–with-debug

Posted at Nginx Forum:

> **[Re: Problem with fastcgi cache](https://forum.nginx.org/read.php?2,217538,217668#msg-217668)**
>
> Hello, I´m working with Nginx v1.0.8. I have the configuration for fastcgi cache: server { listen 8080; //many other lines of configuration fastcgi\_cache\_path /var/www/cache levels=1:2 keys\_zone=zera:10m inactive=5m;

---

<div class="post-metadata">

**Author:** ![firestorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c4cdca/32.png) [@firestorm](https://www.ruby-forum.com/u/firestorm)\
**Post date:** [November 2, 2011, 10:43pm UTC](https://www.ruby-forum.com/t/problem-with-fastcgi-cache/213315/3 "2011-11-02T22:43:44Z")

</div>

Problem solved. The solution was include the statements:

fastcgi\_pass\_header Cookie;  
fastcgi\_ignore\_headers Cache-Control Expires Set-Cookie;

I added the configuration to log the cache request result (HIT or  
MISS):

log\_format cache '$remote\_addr - $remote\_user [$time\_local] “$request”  
’  
'$status $upstream\_cache\_status $body\_bytes\_sent  
“$http\_referer” ’  
‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;

```
access_log logs/access.log cache;

```

And now you can see in the log:

10.35.9.129 - - [02/Nov/2011:12:41:00 -0400] “GET  
/administration.php/school HTTP/1.1” 200 HIT 2712  
“[http://10.128.50.101/administration.php/school](http://10.128.50.101/administration.php/school)” “Mozilla/5.0 (Windows  
NT 5.1; rv:7.0) Gecko/20100101 Firefox/7.0” “-”

Posted at Nginx Forum:

> **[Re: Problem with fastcgi cache](https://forum.nginx.org/read.php?2,217538,217725#msg-217725)**
>
> Hello, I´m working with Nginx v1.0.8. I have the configuration for fastcgi cache: server { listen 8080; //many other lines of configuration fastcgi\_cache\_path /var/www/cache levels=1:2 keys\_zone=zera:10m inactive=5m;
