• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Automatically purge nginx caching afert change content in Wordpress

Tomek

Regular Pleskian
Hi :)

Is there any way to automatically clean nginx caching after adding/updating/removing post/page/comments in Worpdress?
 
Actually, it is not a trivial task which is required a very fast reaction. This is necessary so that from WordPress side something reacts to all these changes and signals the WP toolkit.
At the moment we have no such plans for implementation. Only this solution - How to clear nginx cache?
But could you explain your desired usage scenario in more details? Why do you need this cleaning?
 
Hi Igor :)

Actually, it is not a trivial task which is required a very fast reaction. This is necessary so that from WordPress side something reacts to all these changes and signals the WP toolkit.
At the moment we have no such plans for implementation. Only this solution - How to clear nginx cache?
But could you explain your desired usage scenario in more details? Why do you need this cleaning?

Right now, I use to cache this plugin: WP Super Cache

When I add a new post, the cache is cleared.
When someone adds a new comment on blog, the cache is cleared,
and so on.
So if there are any changes on the webiste, then the cache is refreshed.

I wanted to replace this plugin with nginx cache.

Wordpress has plugins to control nginx cache in this way:
Search Results for “Nginx” | WordPress.org

But it seems that none of them works with Plesk nginx cache.
 
Last edited:
I suppose that problem in that nginx has built-in support for fastcgi_cache but it doesn’t have mechanism to purge cached content built-in. So we need to rely on third-party nginx module - fastcgi_cache_purge module. Without this 3rd party module, cache won’t be updated if you create/edit any post/page in WordPress.
With the command

# nginx -V 2>&1 | grep nginx-cache-purge -o

(no output)
we see that default Plesk nginx is compiled without this module.
 
Igor, thank you so much for explaining mi this :)

What do you think, are there any chances that Plesk adding this module officially? The module is production-ready.
 
What do you think, are there any chances that Plesk adding this module officially? The module is production-ready.
I can say only that we have corresponding feature request PPM-2415 but I have no clue when it may be released.
 
I found a plugin that uses PHP to purge nginx cache:

Nginx Cache

So I created the "cache" folder in /var/www/vhosts/website/httpdocs/
Then I changed proxy cache path in /etc/nginx/plesk.conf.d/vhosts/website.conf to /var/www/vhosts/website/httpdocs/cache

Unfortunately, after reloading nginx, the owner of the cache folder is changed. Php does not have access to it. How to solve this problem?
 
Last edited:
It can't be solved that way. PHP will not have access to the Nginx cache. Has to be done natively by the web server.I think fastcgi_cache_purge is not even supported in open-source Nginx. Only Nginx Plus.
 
Back
Top