Attempting to use fastcgi_param for nginx-helper cache path

Setting up nginx full page cache has made a big difference even with a solid base architecture (HAProxy load balancer for multiple app servers with Nginx + PHP-FPM. I’m encountering a few issues that may / not be related in trying to get the nginx-helper plugin operational to make the content author experience with caching better.

  1. The Purge Entire Cache button works to invalidate all the caches. Yaaah!

  2. The GET request doesn’t work b/c the curl requests cannot complete b/c of environment restrictions on access from the application servers. That’s on environment tho, not the plugin in any way.

  3. The location of cache is not /var/run/nginx-cache so I set the local cache option with RT_WP_NGINX_HELPER_CACHE_PATH in equivalent of wp-config (site architecture loosely based on Roots.io/Trellis so config/application.php). Publish or update posts do show attempts in the log to invalidate, but are not successful at locating cached copies.

For most of our defined constants, I’m using the fastcgi_param in nginx config. This ensures that the source code in repo does not need to know anything about it’s deployment context - and if a deployment is scaled out on different server / user, there is one config which the automated deploy can provide. What is most strange is that RT_WP_NGINX_HELPER_CACHE_PATH will not be read from that method despite showing up in a var_dump of $_SERVER. Other values like WP_HOME and credentials are received fine through it.

Anyone experienced similar issues or could suggest helpful items to remedy. The purge all “nuclear” option is a reasonable fallback but would obviously like to have the more nuanced option.

Updates:

  1. Nginx Config in location block: fastcgi_param RT_WP_NGINX_HELPER_CACHE_PATH /custom/path/to/cache
  1. wp-content equivalent (config/application.php): define( 'RT_WP_NGINX_HELPER_CACHE_PATH', $_SERVER['RT_WP_NGINX_HELPER_CACHE_PATH'] );

Results:

  1. Both Purge Entire Cache and publish / update complete w/o 502 errors.
  2. Purge Entire Cache actually does that.
  3. Publish / update post triggers nginx-helper/nginx.log indicates attempt to invalidate homepage cache but finds no result: 2017-04-30 22:33:51 | INFO | Purging homepage ‘https://examplesite.ca/sitepath/en/’ 2017-04-30 22:33:51 | INFO | - Purging URL | https://examplesite.ca/sitepath/en/ 2017-04-30 22:33:51 | INFO | - - https://examplesite.ca/sitepath/en/ is currently not cached (checked for file: /var/path/to/custom/cache/4/97/5a150c906286d88579aa26b875db9974)

Likely source of remaining issue relates to https://wordpress.org/support/topic/wrong-homepage-cache-cleared-when-wpml-plugin-used/ but specific to Q-Translate-X