rtCamp / nginx-helper

Nginx Helper for WordPress caching, permalinks & efficient file handling in multisite
https://wordpress.org/plugins/nginx-helper/
230 stars 122 forks source link
cache cache-purge fastcgi fastcgi-cache fastcgi-purge-cache nginx nginx-cache nginx-map nginx-purge nginx-wordpress permalinks purge redis redis-cache rewrite wordpress wordpress-plugin

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, 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, akrocks, Vedant-Gandhi

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.5

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.

Description

  1. Removes index.php from permalinks when using WordPress with nginx.
  2. Adds support for purging redis-cache when used as full-page cache created using nginx-srcache-module
  3. Adds support for nginx fastcgi_cache_purge & proxy_cache_purge directive from module. Provides settings so you can customize purging rules.
  4. Adds support for 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.

Tutorials

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

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

Important - Please refer to https://github.com/rtcamp/nginx-helper#frequently-asked-questions for up-to-date FAQs.

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 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:

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:' );

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.

Still need help!

Please post your problem in our free support forum.

Screenshots

1. Nginx plugin settings

Nginx plugin settings

2. Remaining settings

Remaining settings

Changelog

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

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