# Reverse proxy is caching php pages?

**URL:** <https://www.ruby-forum.com/t/reverse-proxy-is-caching-php-pages/222522>\
**Category:** NGINX\
**Created:** [August 31, 2012, 1:33pm UTC](https://www.ruby-forum.com/t/reverse-proxy-is-caching-php-pages/222522 "2012-08-31T13:33:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 31, 2012, 1:33pm UTC](https://www.ruby-forum.com/t/reverse-proxy-is-caching-php-pages/222522/1 "2012-08-31T13:33:13Z")

</div>

I setup a reverse proxy on my forum and everything is working okay. (I  
think?).

http {  
…  
proxy\_cache\_path /usr/local/nginx/cache levels=1:2  
keys\_zone=STATIC:10m inactive=24h max\_size=1g;  
…  
}  
server {  
listen 80;  
#listen [::]:80 ipv6only=on;  
return 301 https://$host$request\_uri;  
}

```
server {
    listen ssl.xxx.yyy:443 ssl spdy;
   #listen [::]:443 ipv6only=on ssl;

    server_name ssl.xxx.yyy;

    ssl on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_ciphers

```

ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM;  
ssl\_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;  
ssl\_prefer\_server\_ciphers on;  
ssl\_certificate /usr/local/nginx/ssl/server.pem;  
ssl\_certificate\_key /usr/local/nginx/ssl/ssl.key;  
ssl\_ecdh\_curve secp521r1;

```
    keepalive_timeout 300;

    add_header Strict-Transport-Security "max-age=7776000;

```

includeSubdomains";

```
    error_page 502 504 /offline.html;

    location / {
        proxy_pass http://xxx.xxx.xxx.xxx/;
        proxy_set_header Host xxx.yyy;
        proxy_set_header CF-Connecting-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto https;
        proxy_cache STATIC;
        proxy_cache_valid 200 7d;
        proxy_cache_use_stale error timeout invalid_header updating

```

http\_500 http\_502 http\_503 http\_504;  
}

```
    location = /offline.html {
        root html;
    }
}

```

[small note: Do I really even need ssl\_ecdh\_curve? fine without? I can’t  
find documentation on it so idk why I’m using it]

Config on my main site:

server {  
listen [::]:80 ipv6only=on; # listen for IPv6 only traffic on  
IPv6  
sockets  
listen 80; # listen also for IPv4 traffic on “regular” IPv4  
sockets

```
    server_name xxx.yyy;

    client_max_body_size 30M; #for large file uploads

    access_log /home/web/logs/access.log main;
    error_log /home/web/logs/error.log;

    root /home/web/site;

    error_page 404 403 /404.html;

    location ~ /\.ht {
        deny all;
        return 404;
    }

    location ~ /(addons|data|attachments) {
        deny all;
        return 404;
    }

    location ~ \.php$ {
        try_files $uri = 404;
        fastcgi_pass unix:/tmp/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
include fastcgi\_params;  
}

```
    location ~ \.(?:ico|css|js|gif|jpe?g|png)$ {
        expires 90d;
        add_header Cache-Control public;
    }

    location ~ \.(?:html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
        expires 180s;
        add_header Cache-Control "public, must-revalidate";
    }
}

```

When I have scripts that should not be cached they get cached. For  
example  
if I have a script that displays my IP address, visiting that page on  
the  
reverse proxy it gets cached and is publicly viewable to everyone. How  
can I  
prevent the reverse proxy from caching PHP pages or pages ending in  
.php?

Posted at Nginx Forum:

> **[Reverse proxy is caching php pages?](https://forum.nginx.org/read.php?2,230385,230385#msg-230385)**
>
> I setup a reverse proxy on my forum and everything is working okay. (I think?). http { ... proxy\_cache\_path /usr/local/nginx/cache levels=1:2 keys\_zone=STATIC:10m inactive=24h max\_size=1g; ... } server { listen
