Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2
Nginx Cache Purge Preload for Wordpress (NPP). The most comprehensive solution for managing Nginx (FastCGI, Proxy, SCGI, UWSGI) cache operations directly from your WordPress dashboard.
License
psaux-it/nginx-fastcgi-cache-purge-and-preload
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
🚀Support this project! If NPP has improved your workflow, consider giving it a ⭐ to help us grow:
🚀Need help with server-side integration? Check out our tailored services:
![]() | WordPress solution for Nginx Cache management |
---|
NPP allows WordPress users to manage Nginx Cache operations directly from the WordPress admin dashboard, enhancing website performance and caching efficiency. NPP supports NginxFastCGI,Proxy,SCGI, andUWSGI cache purge and preload operations, making it the most comprehensive solution for managing Nginx Cache from your WordPress dashboard.
Check outDockerized repository that provides a complete full-stack deployment forNPP. It includes pre-configured Dockerfiles, a Docker Compose setup, and detailed instructions to get your site running in minutes. Maintained alongside the mainNPP plugin. It’s ideal for production, development, and testing environments, offering a streamlined way to simplify your deployment workflow with containerized solutions. If you are onAll-in-One Monolithic Server arc you can still use pre-made automation bash script below.
NPP is compatible exclusively withNginx web servers running onLinux-powered systems. Additionally, theshell_exec function must be enabled and unrestricted. Consequently, the plugin may not operate fully on shared hosting environments where native Linux commands are blocked from running via PHP.
Moreover, granting the correct permissions to the PHP process owner (PHP-FPM-USER) is essential for the proper functioning of the purge and preload operations. This is necessary in isolated user environments that have two distinct user roles: the WEBSERVER-USER and the PHP-FPM-USER.
📌 If you see warnings or if any plugin settings or tabs are disabled, this could indicate permission issues, an unsupported environment, or missing dependencies that the plugin requires to function properly.NPP is completely free OpenSource project!
📌 You do not need any external Nginx module. If you're deploying on anAll-in-One Monolithic Server simply execute the following one liner after installing plugin and follow instructions.
➡️bash <(curl -Ss https://psaux-it.github.io/install.sh)
➡️Purge All Nginx Cache: Completely clear all cached data stored by Nginx.
➡️Preload All Nginx Cache: Populate the Nginx cache with the most recent data for the entire website.
➡️Auto Preload Nginx Cache: Automatically preload the cache after purging, ensuring fast page load times by caching content proactively. This feature is triggered whenAuto Purge
is enabled for a singlepost/page
or when thePurge All
cache action is used.
➡️Auto Purge Nginx Cache: The cache is automatically purged when theactive theme
is updated,a plugin
is activated, updated, or deactivated, or whencompatible caching plugins
trigger a purge. Forposts/pages
, the cache is cleared whencontent is updated
or acomment’s
status changes. IfAuto Preload
is enabled, the cache for thepost/page
or theentire site
is reloaded after purging, ensuring your content remains up-to-date.
➡️Schedule Cache Purge & Preload via WP Cron: Automate the purge and preload process using WordPress Cron jobs.
➡️Remote Nginx Cache Purge & Preload via REST API: Remotely trigger cache purging and preloading throughREST API
endpoints.
➡️Manual Nginx Cache Purge & Preload: Allow manual purging and preloading of cache through the table view in Advanced Tab.
➡️On-Page Nginx Cache Purge & Preload: Manually purge and preload Nginx cache for the currently visited page directly from the frontend.
➡️Custom Cache Key Support: Define a regex pattern to parse URLs based on your custom(fastcgi|proxy|uwsgi|scgi)_cache_key
format.
➡️Optimized Nginx Cache Preload: Enhance Nginx cache preload performance with options to limit server resource usage, via exclude endpoints, exclude file extensions, wait retrievals and rate limiting.
➡️Monitor Plugin and Nginx Cache Status: Monitor plugin status, cache status, cache preload status, and Nginx status from the Status tab.
➡️User-Friendly Interface: Easy-to-use AJAX-powered settings, integrated into the WordPress admin bar for quick access.
➡️Admin Notices and Logs: Receive handy notifications and view logs for plugin status and all cache-related actions within the WordPress admin area.
➡️Email Notifications: Receive email alerts upon completion of preload actions, with customizable templates to suit your needs.
NPP automates Nginx cache purging and preloading in WordPress environments where WEBSERVER-USER and PHP-FPM-USER operate separately. Unlike external Nginx modules, NPP directly removes cache files from the cache directory, provided PHP-FPM-USER has the necessary permissions. This method eliminates the need for direct Nginx interaction, offering greater flexibility for managing cache operations, particularly in modern containerized environments.
To ensure PHP-FPM-USER has the required permissions, NPP includes a pre-configured bash script that can be manually executed on the host, making it easy to get started and benefit from the plugin.
- Download latestplugin from official wordpress plugin repository or from our latestreleases and install to your wordpress instance also you can search plugin on wordpress admin dashboard as 'fastcgi cache purge and preload for nginx'
- Call
install.sh
one liner to start automated setup;
Switch toroot
user:
sudo su - root|| su - rootbash<(curl -Ss https://psaux-it.github.io/install.sh)
or directly withsudo
sudo bash -c"$(curl -Ss https://psaux-it.github.io/install.sh)"
Theinstall.sh
script serves as a wrapper for executing the mainfastcgi_ops_root.sh
script fromour automation repository. This script is designed for theNPP WordPress plugin, which can be found atOfficial WordPress Plugin Repository.
The script first attempts to automatically identify the PHP-FPM-USER along with their associated Nginx Cache Paths. If cannot automatically match the PHP-FPM-USER with their respective Nginx Cache Path, provides an easy manual setup option using themanual-configs.nginx
file, where users can add multiple PHP-FPM-USER and their associated Nginx Cache Paths.
In environments with two distinct user roles—the WEBSERVER-USER and the PHP-FPM-USER —this script automates the management of Nginx Cache Paths.Utilizesbindfs
to create aFUSE
mount of the original Nginx Cache Paths, enabling the PHP-FPM-USER to write to these directories with the necessary permissions. This approach resolves permission conflicts by granting the PHP-FPM-USER access to a new mount point, while keeping the original Nginx Cache Paths intact and synchronized.
After the setup (whether automatic or manual) completed, the script creates annpp-wordpress
systemd service that can be managed from the WordPress admin dashboard under the NPP pluginSTATUS tab.
Additionally, NPP users have the flexibility to manage FUSE mount and unmount operations for the original Nginx Cache Path directly from the WP admin dashboard, effectively preventing unexpected permission issues and maintaining consistent cache stability.
These instructions guide you through setting up the NPP plugin in environments wherePHP-FPM-USER
andWEBSERVER-USER
are distinct, manually, without the automation scriptinstall.sh
- Web Server:
NGINX
configured with caching. - Example Users:
PHP-FPM-USER
(PHP process owner, e.g.,psauxit
).WEBSERVER-USER
(commonlynginx
orwww-data
).
- Tools: A Linux-based server withbindfs installed.
- Original Nginx Cache Path:
/dev/shm/fastcgi-cache-psauxit
- FUSE Mount Point:
/dev/shm/fastcgi-cache-psauxit-mnt
- This mount path will be used as the Nginx Cache Path in the NPP plugin settings.
Installbindfs using your Linux distribution's package manager:
# For Gentooemerge --ask sys-fs/bindfs# For Debian/Ubuntusudo apt install bindfs# For Red Hat/CentOSsudo yum install bindfs
Create a new directory for the FUSE mount:
mkdir /dev/shm/fastcgi-cache-psauxit-mnt
Mount the original Nginx cache path to the FUSE mount directory with the appropriate permissions forpsauxit
:
bindfs -u psauxit -g psauxit --perms=u=rwx:g=rx:o= /dev/shm/fastcgi-cache-psauxit /dev/shm/fastcgi-cache-psauxit-mnt
To make the mount persistent, add the following line to/etc/fstab
:
bindfs#/dev/shm/fastcgi-cache-psauxit /dev/shm/fastcgi-cache-psauxit-mnt fuse force-user=psauxit,force-group=psauxit,perms=u=rwx:g=rx:o= 0 0
After editing/etc/fstab
, apply the changes:
mount -a
- Go to theNPP plugin settings page in your WordPress dashboard.
- Set
/dev/shm/fastcgi-cache-psauxit-mnt
as theNginx Cache Path. - Check the pluginStatus tab for any warnings.
npp.2.mp4
Here is the short explanation of proper php-fpm nginx setup
The PHP-FPM user should be a special user that you create for running your website, whether it is Magento, WordPress, or anything.
NGINX must run with it own unprivileged user, which isnginx (RHEL-based systems) orwww-data (Debian-based systems).
We must connect things up so that WEBSERVER-USER can read files that belong to the PHP-FPM-GROUPThis will allow us to control what WEBSERVER-USER can read or not, via group chmod permission bit.
Granting additional group permissions to the "nginx/www-data" user can potentially introduce security risks due to the principle of least privilege. Your PHP-FPM-USER should never have sudo privileges, even if it's not listed in the sudoer list, as this can still pose security drawbacks. Therefore, we will set the website content's group permission to "g=rX" so that "nginx/www-data" can read all files and traverse all directories, but not write to them.
usermod -a -G PHP-FPM-GROUP WEBSERVER-USER
This reads as: add WEBSERVER-USER (nginx/www-data) to PHP-FPM-GROUP (websiteuser group).
chown -R PHP-FPM-USER:PHP-FPM-GROUP /home/websiteuser/websitefiles
Here is a simple rule: all the files should be owned by the PHP-FPM-USER and the PHP-FPM-GROUP:
chmod -R u=rwX,g=rX,o= /home/websiteuser/websitefiles
This translates to the following:
- PHP-FPM-USER can read, write all files, and read all directories
- PHP-FPM-GROUP (meantime WEBSERVER-USER) can read all files and traverse all directories, but not write
- All other users cannot read or write anything
../fpm-php/fpm.d/websiteuser.conf
[websiteuser.com]user = PHP-FPM-USERgroup = PHP-FPM-GROUPlisten.owner = WEBSERVER-USERlisten.group = WEBSERVER-GROUPlisten.mode = 0660listen = /var/run/php-fcgi-websiteuser.sock
This is proper php-fpm nginx setup example.
About
Nginx Cache Purge Preload for Wordpress (NPP). The most comprehensive solution for managing Nginx (FastCGI, Proxy, SCGI, UWSGI) cache operations directly from your WordPress dashboard.
Topics
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.