# Proxy\_cache not working

**URL:** <https://www.ruby-forum.com/t/proxy-cache-not-working/208649>\
**Category:** NGINX\
**Created:** [June 23, 2011, 12:23pm UTC](https://www.ruby-forum.com/t/proxy-cache-not-working/208649 "2011-06-23T12:23:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 23, 2011, 12:23pm UTC](https://www.ruby-forum.com/t/proxy-cache-not-working/208649/1 "2011-06-23T12:23:49Z")

</div>

Greetings

I’m trying to setup reverse proxy cache but the cache path is always  
empty and tcpdump tells me there is no caching. Here is my configuration  
(all non-mentioned files are default):

$ cat /etc/nginx/conf.d/cache.conf  
proxy\_cache\_path /var/cache/nginx levels=1:2 keys\_zone=disk-cache:8m  
max\_size=1000m inactive=600m;  
proxy\_temp\_path /tmp/nginx;

/etc/nginx/sites-enabled/default:  
location ~ ^/userProfileConfig($|/.\*) {

```
    proxy_cache disk-cache;
    proxy_cache_valid any 1m;

    proxy_pass http://10.82.0.150:8888;
    proxy_redirect off;
    proxy_buffering on;

    proxy_set_header HOST $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For

```

$proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Proto $scheme;

```
    access_log /var/log/nginx/access.test.log;
    error_log /var/log/nginx/error.test.log info;

}

```

There are no errors.

Additional info:

$ cat /etc/lsb-release  
DISTRIB\_ID=Ubuntu  
DISTRIB\_RELEASE=10.04  
DISTRIB\_CODENAME=lucid  
DISTRIB\_DESCRIPTION=“Ubuntu 10.04.2 LTS”

$ nginx -V  
nginx version: nginx/0.7.65  
TLS SNI support enabled  
configure arguments: --conf-path=/etc/nginx/nginx.conf  
–error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid  
–lock-path=/var/lock/nginx.lock  
–http-log-path=/var/log/nginx/access.log  
–http-client-body-temp-path=/var/lib/nginx/body  
–http-proxy-temp-path=/var/lib/nginx/proxy  
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug  
–with-http\_stub\_status\_module --with-http\_flv\_module  
–with-http\_ssl\_module --with-http\_dav\_module  
–with-http\_gzip\_static\_module --with-http\_realip\_module --with-mail  
–with-mail\_ssl\_module --with-ipv6  
–add-module=/build/buildd/nginx-0.7.65/modules/nginx-upstream-fair

$ curl [http://192.168.122.22/userProfileConfig/1/1](http://192.168.122.22/userProfileConfig/1/1)

\<?xml version='1.0' encoding='UTF-8'?\>...............

$ cat /var/log/nginx/access.test.log  
192.168.122.1 - - [23/Jun/2011:11:40:53 +0200] “GET  
/userProfileConfig/1/1 HTTP/1.1” 200 1123 “-” “Mozilla/5.0 (X11; Linux  
x86\_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1”  
192.168.122.1 - - [23/Jun/2011:11:44:01 +0200] “GET  
/userProfileConfig/1/1 HTTP/1.1” 200 1123 “-” “curl/7.21.3  
(x86\_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4  
libidn/1.18”

$ sudo du -h /var/cache/nginx/  
4.0K /var/cache/nginx/

$ ls -l /var/cache/ | grep nginx  
drwx------ 2 www-data root 4096 2011-06-23 11:41 nginx

Any help will be greatly appreciated.

Thanks in advance.  
David.

Posted at Nginx Forum:

> **[proxy\_cache not working](https://forum.nginx.org/read.php?2,209334,209334#msg-209334)**
>
> Greetings I'm trying to setup reverse proxy cache but the cache path is always empty and tcpdump tells me there is no caching. Here is my configuration (all non-mentioned files are default): $ cat /etc/nginx/conf.d/cache.conf proxy\_cache\_path...

---

<div class="post-metadata">

**Author:** ![dekar411](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d9b06d/32.png) [@dekar411](https://www.ruby-forum.com/u/dekar411)\
**Post date:** [June 23, 2011, 2:28pm UTC](https://www.ruby-forum.com/t/proxy-cache-not-working/208649/2 "2011-06-23T14:28:03Z")

</div>

Hello!

On Thu, Jun 23, 2011 at 06:23:24AM -0400, dekar411 wrote:

> I’m trying to setup reverse proxy cache but the cache path is always  
> empty and tcpdump tells me there is no caching. Here is my configuration  
> (all non-mentioned files are default):

Most likely reason is that response headers (Cache-Control,  
Expires, presence of Set-Cookie header) disable caching.

Maxim D.

---

<div class="post-metadata">

**Author:** ![dekar411](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d9b06d/32.png) [@dekar411](https://www.ruby-forum.com/u/dekar411)\
**Post date:** [June 23, 2011, 3:21pm UTC](https://www.ruby-forum.com/t/proxy-cache-not-working/208649/3 "2011-06-23T15:21:57Z")

</div>

> Most likely reason is that response headers  
> (Cache-Control,  
> Expires, presence of Set-Cookie header) disable  
> caching.
> 
> Maxim D.

You are right, adding:

proxy\_ignore\_headers Cache-Control Expires;

Fixes the problem.

Thanks a lot!

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,209334,209377#msg-209377](http://forum.nginx.org/read.php?2,209334,209377#msg-209377)
