Purge doesn't work

I followed the tutorial to install nginx + purge module, used the config file that were in the post. Cache seems to be working. But cache is just purged when I do it on manual mode: http://mywordpressblog.com/purge/2013/12/post-link

When I try to purge the cache using the “Purge Cache” button from Nginx Helper plugin, the cache is not purger. What should I do?


One more thing: when I update a post, the cache for the post which is updated is cleared perfectly.

Do you have same PHP and Nginx user?

Manual purge happens directly from Nginx.

In “Purge Cache”, PHP try to delete files directly. If PHP and Nginx are run by different system users, deletion may fail.

Hello Rahul,

I tried to do what you asked. However, changing the user from “apache” (which was the default) to “nginx” (which is the user that runs nginx processes), the cache doesn’t seems to work. They are generated in nginx-cache folder, they are also removed when I press the “Purge cache” button, but the timestamp in the HTML source keeps changing on every page refresh made by my browser.

Cache is being generated, purge button now remove content, but it’s like the cached files aren’t read by nginx.

Any suggestion?


Okay, I think it was fixed by changing nginx user, not php user. :stuck_out_tongue:

Glad to know that your issue is fixed.

If you are using Apache with Nginx then please stop that. Nginx should be used directly with PHP-FPM for WordPress sites.

I came here for the same issue and the answer is probably the same. However, I wondered if there is a way to make this work and still allow individual users for sites. IOW, my Nginx is run under www-data and PHP under group: www-data and user: the owner of the site, who is also a member of www-data. This has worked fine for everything else so I tried changing nginx-cache from www-data:root to www-data:www-data (the same as the subfolders and files) and the Purge Cache button worked. Do you foresee any issues with this? Thanks.

Edit: Never mind, I was so tired that I had forgotten to change permissions back on the rest of my setup so it was essentially still all using the same user. It looks like to have this functionality there is no way around this. Thanks.

@david-rahrer As of now, group-permission is the only way-out. We will be using group-permission workaround when we will add shared-hosting feature to easyengine project - https://github.com/rtCamp/easyengine/

OK, so just to clarify, if I have different users for each pool, and nginx is running under www-data but the pool using the cache is running under something else, then I cannot use “purge”? I suppose that makes sense, because if I chmod everything in /var/run/nginx-cache to +rw for everyone, then purge works, but as soon as the cache builds up, the permissions are just 0600 again, under the “wrong” user.

I can “hard purge” the cache by doing an rm -rf of course, but that seems a bit of a “manual” way to do it.

The /purge/ method also works, as does purging when updating a page.

I noticed in the docs that there’s something called fastcgi_store_access http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_store_access

However, even though I set it up to all:rw and restarted, it was still writing the files with 0600 permission and “purge all” still didn’t work. Hmmm… I don’t really want to go back to “one user for all pools”, as that’s a bit insecure.