Stars: 206
Forks: 107
Pull Requests: 160
Issues: 149
Watchers: 49
Last Updated: 2023-09-01 23:03:56
Nginx Helper for WordPress caching, permalinks & efficient file handling in multisite
License:
Languages: CSS, JavaScript, PHP, TypeScript
Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, darren-slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel, gagan0123, ravanh, michaelbeil, samedwards, niwreg, entr, nuvoPoint, iam404, rittesh.patel, vishalkakadiya, BhargavBhandari90, vincent-lu, murrayjbrown, bryant1410, 1gor, matt-h, pySilver, johan-chassaing, dotsam, sanketio, petenelson, nathanielks, rigagoogoo, dslatten, jinschoi, kelin1003, vaishuagola27, rahulsprajapati, Joel-James, utkarshpatel, gsayed786, shashwatmittal, sudhiryadav, thrijith, stayallive, jaredwsmith, abhijitrakas, umeshnevase, sid177, souptik, arafatkn, subscriptiongroup
Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
Requires at least: 3.0
Tested up to: 6.1
Stable tag: 2.2.3
License: GPLv2 or later (of-course)
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Donate Link: http://rt.cx/eedonate
Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
index.php
from permalinks when using WordPress with nginx.map{..}
on a WordPress-multisite network installation. Using it, Nginx can serve PHP file uploads even if PHP/MySQL crashes. Please check the tutorial list below for related Nginx configurations.You will need to follow one or more tutorials below to get desired functionality:
Automatic Installation
Manual Installation
/wp-content/plugins/
directory on your WordPress installation.For proper configuration, check out our tutorial list in the Description tab.
Important - Please refer to https://github.com/rtcamp/nginx-helper#frequently-asked-questions for up-to-date FAQs.
Q. Will this work out of the box?
No. You need to make some changes at the Nginx end. Please check our tutorial list.
Q. There's a 'purge all' button? Does it purge the whole site?
Yes, it does. It physically empties the cache directory. It is set by default to /var/run/nginx-cache/
.
If your cache directory is different, you can override this in your wp-config.php by adding
define('RT_WP_NGINX_HELPER_CACHE_PATH','/var/run/nginx-cache/');
Replace the path with your own.
Q. Does it work for custom posts and taxonomies?
Yes. It handles all post-types the same way.
Q. How do I know my Nginx config is correct for fastcgi purging?
Manually purging any page from the cache, by following instructions in the previous answer.
Version 1.3.4 onwards, Nginx Helper adds a comment at the end of the HTML source ('view source' in your favourite browser):
<!--Cached using Nginx-Helper on 2012-10-08 07:01:45. It took 42 queries executed in 0.280 seconds.-->
. This shows the time when the page was last cached. This date/time will be reset whenever this page is purged and refreshed in the cache. Just check this comment before and after a manual purge.
As long as you don't purge the page (or make changes that purge it from the cache), the timestamp will remain as is, even if you keep refreshing the page. This means the page was served from the cache and it's working!
The rest shows you the database queries and time saved on loading this page. (This would have been the additional resource load, if you weren't using fast-cgi-cache.)
Q. I need to flush a cached page immediately! How do I do that?
Nginx helper plugin handles usual scenarios, when a page in the cache will need purging. For example, when a post is edited or a comment is approved on a post.
To purge a page immediately, follow these instructions:
Q. Can I override the redis hostname, port and prefix?
Yes, you can force override the redis hostname, port or prefix by defining constant in wp-config.php. For example:
define( 'RT_WP_NGINX_HELPER_REDIS_HOSTNAME', '10.0.0.1' );
define( 'RT_WP_NGINX_HELPER_REDIS_PORT', '6000' );
define( 'RT_WP_NGINX_HELPER_REDIS_PREFIX', 'page-cache:' );
Q. My multisite already uses WPMU_ACCEL_REDIRECT
. Do I still need Nginx Map?
Definitely. WPMU_ACCEL_REDIRECT
reduces the load on PHP, but it still ask WordPress i.e. PHP/MySQL to do some work for static files e.g. images in your post. Nginx map lets nginx handle files on its own bypassing wordpress which gives you much better performance without using a CDN.
Q. I am using X plugin. Will it work on Nginx?
Most likely yes. A wordpress plugin, if not using explicitly any Apache-only mod, should work on Nginx. Some plugin may need some extra work.
Please post your problem in our free support forum.
rt_nginx_helper_purge_cached_file
hook. #271 - by Arafat Islamrt_nginx_helper_after_purge_all
to fire after the entire cache has been purged whatever caching type is used. #232 - by Julien-prrsrt_nginx_helper_fastcgi_purge_suffix
to change purge suffix for FastCGI cache. #141 - by stayallivert_nginx_helper_fastcgi_purge_url_base
to change purge URL base for FastCGI cache. #141 - by stayallivert_nginx_helper_purge_url
to filter the URL to be purged. #182 - by todevenirt_nginx_helper_purge_cached_file
to filter the cached file name. #182 - by todevenirt_nginx_helper_remote_purge_url
to filter remote URL to be purged. #182 - by todevenirt_nginx_helper_after_fastcgi_purge_all
to fire after the FastCGI cache has been purged. #182 - by todevenirt_nginx_helper_after_redis_purge_all
to fire after the Redis cache has been purged. #182 - by todevenirt_nginx_helper_purged_file
to fire an action after deleting file from cache. #182 - by todevenirt_nginx_helper_before_remote_purge_url
to fire an action before purging remote URL. #182 - by todevenirt_nginx_helper_after_remote_purge_url
to fire an action after remote purge request. #182 - by todeveniSUBDOMAIN_INSTALL
. #189 - by ChrisHardieAdded custom purge URL option.
Fix purging for Redis cache and FastCGI cache
Fix purging for custom post types
Added Redis cache purge support.
Fixed PHP notice for an undefined index when "Enable Logging" is not set.
Updated readme and changelog
Fix url escaping #82 - by javisperez
rt_nginx_helper_purge_all
to purge cache from other plugins - by gungeekatxunlink
related error-messages which can be safely ignored.Nginx Helper 2.2.3, Fix performance issue when saving nav menus, purging date archives for CPTs, purge page and post URLs when the post is trashed and passes the URL being purged in "rt_nginx_helper_purge_cached_file" hook as parameter.