# Caching Problem

**URL:** <https://www.ruby-forum.com/t/caching-problem/200756>\
**Category:** NGINX\
**Created:** [December 21, 2010, 12:54pm UTC](https://www.ruby-forum.com/t/caching-problem/200756 "2010-12-21T12:54:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 21, 2010, 12:54pm UTC](https://www.ruby-forum.com/t/caching-problem/200756/1 "2010-12-21T12:54:57Z")

</div>

Hello,

i got a clustered setup, where the content is beeing served from a nfs  
share. thats why i want to cache the static components via nginx, but  
unfortanly i didnt get it to work.

Heres my Config:

Global Configuration nginx.conf section http

```
 proxy_cache_path /var/www/cache levels=1:2 keys_zone=ccdscache:32m

```

max\_size=1000m inactive=7d;  
proxy\_temp\_path /var/www/cache/tmp;

Vhost Config

server {  
listen 80;  
server\_name xxx;

```
     location /server_status {

     stub_status on;
     access_log off;
     allow 127.0.0.1;
     allow xyz;
     deny all;
  }

     location ~*

```

.(jpg|png|gif|jpeg|css|js|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$  
{  
root /srv2/xxx/htdocs;  
proxy\_cache ccdscache;  
proxy\_cache\_valid 200 1m;  
proxy\_cache\_key backend$request\_uri;  
proxy\_cache\_use\_stale error timeout  
invalid\_header;

}

```
     location / {
         root /srv2/xxx/htdocs;
         index index.php index.html;
         if (!-e $request_filename) {
             rewrite ^/(.*)$ /index.php?q=$1 last;
             break;
         }
     }

     error_page 404 /index.php;

```

# error\_page 500 502 503 504 /50x.html;

```
     location = /50x.html {
         root html;
     }

     location ~ \.php$ {
         root /srv2/xxx/htdocs;
          proxy_cache ccdscache;
          proxy_cache_valid 200 302 60m;
          proxy_cache_valid 404 1m;
           proxy_cache_key backend$request_uri;
            proxy_cache_valid 200 1h;
            proxy_cache_use_stale error timeout invalid_header;

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

```

/srv2/xxx/htdocs$fastcgi\_script\_name;  
include /etc/nginx/fastcgi\_params;

```
     }
 }

```

any ideas whats wrong here?

Thanks!

---

<div class="post-metadata">

**Author:** ![gromminger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gromminger](https://www.ruby-forum.com/u/gromminger)\
**Post date:** [December 21, 2010, 1:01pm UTC](https://www.ruby-forum.com/t/caching-problem/200756/2 "2010-12-21T13:01:13Z")

</div>

Hi,

> any ideas whats wrong here?

You’re using “proxy\_cache\_\*” (which works only with “proxy\_pass”) with  
static files and FastCGI.

For FastCGI use “fastcgi\_cache\_\*”, for static files use ngx\_slowfs\_cache  
[1].

[1] [FRiCKLE Labs / nginx / ngx\_slowfs\_cache](http://labs.frickle.com/nginx_ngx_slowfs_cache/)

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

---

<div class="post-metadata">

**Author:** ![gromminger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gromminger](https://www.ruby-forum.com/u/gromminger)\
**Post date:** [December 21, 2010, 1:26pm UTC](https://www.ruby-forum.com/t/caching-problem/200756/3 "2010-12-21T13:26:20Z")

</div>

Thanks 🙂

Am 21.12.10 12:59, schrieb Piotr S.:
