1. rtCamp
  2. nginx-helper

Repository navigation

More items

rtCamp

nginx-helper

Public

About

Nginx Helper for WordPress caching, permalinks & efficient file handling in multisite

wordpress.org/plugins/nginx-helper/

Topics

cachecache-purgefastcgifastcgi-cachefastcgi-purge-cachenginxnginx-cachenginx-mapnginx-purgenginx-wordpresspermalinksproductionpurgeredisredis-cacherewritetier-1wordpresswordpress-plugin

Resources

Readme

Activity

Custom properties

Stars

237 stars

Watchers

42 watching

Forks

134 forks

Report repository

master

BranchesTags

Go to file

Code

Open more actions menu

Latest commit

 

History

918 Commits

918 Commits

Folders and files

NameName

Last commit message

Last commit date

.github

.github

 

 

admin

admin

 

 

assets/js

assets/js

 

 

includes

includes

 

 

languages

languages

 

 

tests

tests

 

 

utils

utils

 

 

wpassets

wpassets

 

 

.distignore

.distignore

 

 

.editorconfig

.editorconfig

 

 

.gitattributes

.gitattributes

 

 

.gitignore

.gitignore

 

 

Development.md

Development.md

 

 

README.md

README.md

 

 

class-nginx-helper-wp-cli-command.php

class-nginx-helper-wp-cli-command.php

 

 

composer.json

composer.json

 

 

composer.lock

composer.lock

 

 

index.php

index.php

 

 

nginx-helper.php

nginx-helper.php

 

 

phpcs.xml

phpcs.xml

 

 

readme.txt

readme.txt

 

 

uninstall.php

uninstall.php

 

 

View all files

Repository files navigation

More items

EasyEngine Cache Helper for Nginx & Cloudflare (formerly Nginx Helper)

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

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, bryant1410, 1gor, matt-h, dotsam, nathanielks, rigagoogoo, dslatten, jinschoi, kelin1003, vaishuagola27, rahulsprajapati, utkarshpatel, gsayed786, shashwatmittal, sudhiryadav, thrijith, stayallive, jaredwsmith, abhijitrakas, umeshnevase, sid177, souptik, arafatkn, subscriptiongroup, akrocks, vedantgandhi28, GridPane, stefanfisk, SGr33n, agvs, diepbui4157, pratiklondhe, webdados, ghost, tjalexander70, mrrobot47, alexliii, joelmcdwebworks, bozzmedia, millionleave, kubajosef, alexsina, tomeryatir, minzak, peterdowney01, rayeason, gnif, thisismyurl, DAnn2012, sarthak8858, im3dabasia1, gutobenn, tores54, mcsr, sarthaknagoshe2002, Titan21, smartyp, kmille, todeveni

Tags: nginx, cache-purge, fastcgi, cloudflare, redis-cache

Requires at least: 5.6

Tested up to: 7.1

Requires PHP: 7.4

Stable tag: 3.0.0

License: GPLv2 or later (of-course)

License URI: http://www.gnu.org/licenses/gpl-2.0.html

Donate Link: http://rt.cx/eedonate

Purge Nginx and Redis page cache, plus Cloudflare edge cache with cache tags, when WordPress content changes.

Description

EasyEngine Cache Helper (formerly Nginx Helper) helps keep cached WordPress content fresh across Nginx FastCGI or Redis page caching and Cloudflare's edge cache.

The plugin coordinates purging; it does not install or configure Nginx, Redis, or Cloudflare for you. For Nginx setup, see the configuration tutorials. For Cloudflare, proxy the site through Cloudflare, provide a scoped API token and Zone ID, and set up the cache rule in the Cloudflare tab.

Existing Nginx features, including permalink handling and multisite map support, remain available.

Tutorials

You will need to follow one or more tutorials below to get desired functionality:

Credits

The Cloudflare cache purge feature is adapted from the Pantheon Advanced Page Cache plugin, Copyright Pantheon Systems, licensed under GPLv2 or later. https://github.com/pantheon-systems/pantheon-advanced-page-cache

The derived code has been modified to emit Cloudflare Cache-Tag headers instead of Surrogate-Key headers.

Installation

Automatic Installation

  1. Log in to your WordPress admin panel, navigate to the Plugins menu and click Add New.
  2. In the search field type “Nginx Helper” and click Search Plugins. From the search results, pick Nginx Helper and click Install Now. Wordpress will ask you to confirm to complete the installation.

Manual Installation

  1. Extract the zip file.
  2. Upload them to /wp-content/plugins/ directory on your WordPress installation.
  3. Then activate the Plugin from Plugins page.

For proper configuration, check out our tutorial list in the Description tab.

Frequently Asked Questions

Will it work immediately after activation?

The plugin needs a working cache configuration. Nginx or Redis purging requires matching server settings. Cloudflare purging requires a proxied site, a Cloudflare Zone ID, an API token, and an appropriate cache rule. See the Installation section.

Can I use Cloudflare purging without Nginx page-cache purging?

Yes. Configure the Cloudflare tab even if Nginx page-cache purging is disabled. The two settings areas are separate.

How do I enable Cloudflare edge caching?

In the Cloudflare tab, save the Zone ID and an API token with the permissions shown in the settings screen. Then select Setup Cache Rules. The rule enables edge caching for matching requests; check its effect alongside any Cloudflare rules you already use.

What happens if I already have Cloudflare cache rules?

The setup action adds the plugin's rule to the existing cache ruleset if a matching plugin rule is not already present. Review the rule order and the combined behavior in Cloudflare after setup.

How is Cloudflare cache purged when content changes?

The plugin adds cache tags to cacheable responses and requests tag purges when relevant WordPress posts, terms, comments, or other supported content changes. Cloudflare must cache the response with those tags for this to work.

Can I purge one page manually?

Yes. An administrator can visit the page while logged in and use Clear Cloudflare Edge Cache in the toolbar to purge that URL from Cloudflare. When Nginx purging is enabled, Purge Current Page handles the configured Nginx or Redis cache.

What does Purge Entire Cache clear?

It requests a full purge of the configured Nginx or Redis cache and, when Cloudflare is configured, the entire Cloudflare zone cache. A full-zone purge also affects other cached content in that zone. Use it when a narrower purge is insufficient.

Does the plugin purge after WordPress, plugin, or theme updates?

Nginx page-cache purging on those updates is off by default. To enable it, add add_filter( 'rt_wp_nginx_helper_enable_auto_purge_on_any_update', '__return_true' ); in site code. Otherwise the plugin shows an admin reminder to purge manually.

Can I set the Cloudflare token in wp-config.php?

Yes. Define EASYENGINE_CACHE_MANAGER_CLOUDFLARE_API_TOKEN in wp-config.php, then save the Zone ID in the Cloudflare tab. The token field is disabled when the constant is present.

Are there Cloudflare WP-CLI commands?

Version 3.0.0 adds wp cloudflare cache purge-tag <tag>, wp cloudflare cache purge-path <url>, and wp cloudflare cache purge-all. The full purge prompts for confirmation unless --yes is passed.

Where can I get help?

Use the WordPress.org support forum for plugin support, or GitHub issues for reproducible bugs.

FAQ - Installation/Comptability

Q. Will this work out of the box?

No. You need to make some changes at the Nginx end. Please check our tutorial list.

FAQ - Nginx Fastcgi Cache Purge

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 can I purge cache automatically after WordPress/plugin/theme updates?

By default, Nginx Helper does not purge cache on WordPress core, plugin, or theme updates. If you want this behavior, you can enable it using a filter:

add_filter( 'rt_wp_nginx_helper_enable_auto_purge_on_any_update', '__return_true' );

Once enabled, cache will be purged automatically whenever WordPress core, plugins, or themes are updated. If left disabled (default), Nginx Helper will instead show an admin notice after updates, reminding you to purge cache manually.

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): &lt;!--Cached using Nginx-Helper on 2012-10-08 07:01:45. It took 42 queries executed in 0.280 seconds.--&gt;. 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. Does it need any kind of URL structure?

Yes. When setting the URL structure in Nginx configuration file a trailing slash should always be added.

Q. How can I automatically purge cache when WooCommerce product stock reduces after purchase?

Nginx Helper now includes optional WooCommerce integration. If enabled, cache for purchased products or products updated via REST API will be purged automatically.

To use it:

  1. Go to Nginx Helper → Settings → WooCommerce Options.
  2. Tick “Purge product cache on updates”.

This ensures customers always see up-to-date stock status and product information without stale cache.

Note: This option will only be visible if WooCommerce is active.

Q. What are the two different options for ngx_cache_purge module?

We have added support for two versions of the ngx_cache_purge module. The module developed by FRiCKLE is the original implementation that we have supported for a long time. We have now added support for a fork of the module developed by torden, which introduces Nginx module-level wildcard-based purging to help improve performance up to a certain level. You can purge it directly using the following format: https://example.com/* with the PURGE method, which will purge the cache of all descendants.

FAQ - Nginx Redis Cache

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. Can I override the redis socket path, username, password?

Yes, you can force override the redis socket path, username, password by defining constant in wp-config.php. For example:

define( 'RT_WP_NGINX_HELPER_REDIS_UNIX_SOCKET', '/var/run/redis/redis.sock' );

define( 'RT_WP_NGINX_HELPER_REDIS_USERNAME', 'admin' );

define( 'RT_WP_NGINX_HELPER_REDIS_PASSWORD', 'admin' );

FAQ - Nginx Map

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.

FAQ - WP-CLI

Q. How can I update the options using WP-CLI?

wp option patch update rt_wp_nginx_helper_options <option_name> <option_value>

FAQ - Cloudflare Edge Cache

Q. Why is the setup cache rule button not visible?

You need to enter the Zone ID and a API key to allow setting up the Cache Rule.

Q. Why is my cache rule setup failing?

Always ensure that the API key has the permissions listed in the description under the API Key field. If any of the permission is missing, we will not be able to set up the cache rule.

Q. What happens if I already have rulesets for Cloudflare Edge Cache?

The plugin will update those rules to add the required configuration.

Q. How can I purge the entire cache when Cloudflare Edge Cache is activated?

You can use the default Purge Entire Cache button on the settings page to purge the cache. It will purge the Nginx cache if it is activated as well as Cloudflare Edge Cache.

Q. How can I purge the cache of a single page only for Cloudflare Edge Cache?

If you are logged in as a user with purge permissions, you can purge a page by visiting it (for example, https://mydomain.com/my-page) and clicking the Clear Cloudflare Edge Cache button in the admin toolbar.

Still need help!

Please post your problem in our free support forum.

Screenshots

1. Nginx caching and purge settings.

Nginx plugin settings

2. Cloudflare API token, Zone ID, cache TTL, and cache rule setup

Remaining settings

Changelog

3.0.0

2.4.1

2.4.0

2.3.5

2.3.4

2.3.3

2.3.2

2.3.1

2.3.0

2.2.5

2.2.4

2.2.3

2.2.2

2.2.1

2.2.0

2.1.0

2.0.3

2.0.2

2.0.1

2.0.0

1.9.12

1.9.11

1.9.10

1.9.9

1.9.8

1.9.7

1.9.6

1.9.5

Added custom purge URL option.

1.9.4

1.9.3

1.9.2

Fix purging for Redis cache and FastCGI cache

1.9.1

Fix purging for custom post types

1.9

Added Redis cache purge support.

1.8.13

Fixed PHP notice for an undefined index when "Enable Logging" is not set.

1.8.12

Updated readme and changelog

1.8.11

Fix url escaping #82 - by javisperez

1.8.10

1.8.9

1.8.8

1.8.7

1.8.6

1.8.5

1.8.4

1.8.3

1.8.1

1.8

1.7.6

1.7.5

1.7.4

1.7.3

1.7.2

1.7.1

1.7

1.6.13

1.6.12

1.6.11

1.6.10

1.6.9

1.6.8

1.6.7

1.6.6

1.6.5

1.6.4

1.6.3

1.6.2

1.6.1

1.6

1.5

1.4

1.3.9

1.3.8

1.3.7

1.3.6

1.3.5

1.3.4

1.3.3

1.3.2

1.3.1

1.3

1.2

1.1

1.0

Credits

The Cloudflare cache purge feature is adapted from the pantheon-systems/pantheon-advanced-page-cache plugin, Copyright Pantheon Systems, licensed under GPLv2 or later.

The derived code has been modified to emit Cloudflare Cache-Tag headers instead of Surrogate-Key headers.

Upgrade Notice

2.2.3

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.

Does this interest you?

Join us at rtCamp, we specialize in providing high performance enterprise WordPress solutions

About

Nginx Helper for WordPress caching, permalinks & efficient file handling in multisite

wordpress.org/plugins/nginx-helper/

Topics

cachecache-purgefastcgifastcgi-cachefastcgi-purge-cachenginxnginx-cachenginx-mapnginx-purgenginx-wordpresspermalinksproductionpurgeredisredis-cacherewritetier-1wordpresswordpress-plugin

Resources

Readme

Activity

Custom properties

Stars

237 stars

Watchers

42 watching

Forks

134 forks

Report repository

Releases

Packages

Used by

Contributors

Languages