# Cache issue with cms

**URL:** <https://www.ruby-forum.com/t/cache-issue-with-cms/244906>\
**Category:** NGINX\
**Created:** [July 5, 2016, 6:25pm UTC](https://www.ruby-forum.com/t/cache-issue-with-cms/244906 "2016-07-05T18:25:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [July 5, 2016, 6:25pm UTC](https://www.ruby-forum.com/t/cache-issue-with-cms/244906/1 "2016-07-05T18:25:56Z")

</div>

Hi,  
I am using nginx version 1.10.1 with reverse proxy function toward  
Apache 2.2.15 I noticed that if I change something inside backend (eg.  
modify some text on some article), that changes appear on frontend, but  
I still view old post’s content into backend.  
I tried to disable any caching mechanism for /wp-admin and /wp-login  
I hope I did this properly, can you help me in order to figure some  
errors with this configuration?

This is my nginx global config:  
####################################################user nginx  
nginx;worker\_processes 4;  
error\_log /var/log/nginx/error.log;  
events { worker\_connections 1024;}  
http { include /etc/nginx/mime.types; default\_type  
application/octet-stream;

# Defines the cache log format, cache log location# and the main access

log location. log\_format cache '\*\*\*$time\_local ’  
'$upstream\_cache\_status ’ 'Cache-Control:  
$upstream\_http\_cache\_control ’ 'Expires: $upstream\_http\_expires ’  
'$host ’ '“$request” ($status) ’ '“$http\_user\_agent” ’  
'Args: $args ’ 'Wordpress Auth Cookie: $wordpress\_auth ';  
access\_log /var/log/nginx/cache.log cache; access\_log  
/var/log/nginx/access.log;  
# Proxy cache and temp configuration. proxy\_cache\_path  
/mnt/ramdisk/nginx\_cache levels=1:2  
keys\_zone=main:10m max\_size=1g inactive=30m;  
proxy\_temp\_path /mnt/ramdisk/nginx\_temp; proxy\_ignore\_headers  
X-Accel-Expires Expires Cache-Control Set-Cookie; proxy\_hide\_header  
Pragma; proxy\_hide\_header Expires; proxy\_hide\_header  
Cache-Control; expires 1d;

# Gzip Configuration. gzip\_vary off; gzip on; gzip\_disable

msie6; gzip\_static on; gzip\_comp\_level 4; gzip\_proxied any;  
gzip\_types text/plain text/css  
application/x-javascript text/xml  
application/xml application/xml+rss  
text/javascript;  
upstream backend { ip\_hash; server 127.0.0.1:8080; # IP  
goes here. }

This is my nginx’s virtual host config:  
server { listen xxxx.xxxx.xxx.xx:80; # IP goes here.  
server\_name [www.domain.com](http://www.domain.com); # IP could go here.

# Set proxy headers for the passthrough proxy\_set\_header Host

$host; proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for; # Let  
the Set-Cookie header through. proxy\_pass\_header Set-Cookie;

# Max upload size: make sure this matches the php.ini in .htaccess

client\_max\_body\_size 8m;

# Catch the wordpress cookies. # Must be set to blank first for

when they don’t exist. set $wordpress\_auth “”; if  
($http\_cookie ~\* “wordpress\_logged\_in\_[^=]\*=([^%]+)%7C”) {  
set $wordpress\_auth wordpress\_logged\_in\_$1; }

# Set the proxy cache key set $cache\_key

$scheme$host$uri$is\_args$args;

# All media (including uploaded) is under wp-content/ so# instead of

caching the response from apache, we’re just# going to use nginx to  
serve directly from there. location ~\*  
^/(wp-content|wp-includes)/(.\*).(gif|jpg|jpeg|png|ico|bmp|js|css|pdf|doc)$  
{ root /home/domain.com; }

# Don’t cache these pages. location ~\* ^/(wp-admin|wp-login.php){

proxy\_pass [http://backend](http://backend); }  
location / { proxy\_pass [http://backend](http://backend);  
proxy\_cache main; proxy\_cache\_key $cache\_key;  
proxy\_cache\_valid 30m; # 200, 301 and 302 will be cached.  
proxy\_cache\_use\_stale error timeout  
invalid\_header http\_500  
http\_502 http\_504  
http\_404; # 2 rules to dedicate the no caching rule for  
logged in users. proxy\_cache\_bypass $wordpress\_auth; # Do not  
cache the response. proxy\_no\_cache $wordpress\_auth; # Do not  
serve response from cache. proxy\_buffers 8 2m;  
proxy\_buffer\_size 10m; proxy\_busy\_buffers\_size 10m; }  
}}  
Thank you very much
