Nginx Helper plugin settings > Prefix


#1

Upon creating a fresh site. Should also reflect and sync on what’s been added to wp-config.php.

Right now, prefix value is the default string. Or maybe add some notes after site creation.


#2

Hi @RoldanLT

Apart from what comes by default with Wordpress , whatever that EasyEngine adds to wp-config.php is subject to the options you pass to ‘ee’ while a wordpress site creation .

I appreciate your suggestion , plz let me know if I missed out on something.

Thanks


#3

So is it possible you also automate the prefix on wp-admin options upon site create or update?


#4

Hi @RoldanLT

The prefix for Nginx helper is not added in wp-config.php .

Further could you please clarify the query in detail and describe your use-case .

Thanks .


#5

EE automatically added this code on config right?

define( 'WP_CACHE_KEY_SALT', 'sitename:' );

I thought that prefix should be the same on Nginx Helper Prefix/Wp Admin option?


#6

Hi @RoldanLT

Prefixes are means to organize cache-stores .

  1. The prefix field that you see in nginx-helper plugins setting page is meant for Page-caching done by Fast-CGI .
  2. The prefix defined by ‘define( 'WP_CACHE_KEY_SALT', 'sitename:' );’ that EasyEngine adds to wp-config.php is meant for Redis Object-Cache .

Its a must that, if you have multiple vhosts configured for redis-object caching on a single server, you must use different cache-store for each , that’s why we explicitly define different cache-store for each vhost in wp-config.php using ‘define( 'WP_CACHE_KEY_SALT', 'sitename:' );

Thanks


#7

That’s not what I talking about. I mean the prefix for Redis Cache also. Nginx Helper also support Redis as option.


#8

HI @RoldanLT

  • The prefix field that you see in Nginx-helper plugin’s setting page is meant for Page-caching done by Redis.

Sorry for any confusion caused.


#9

Yes, so it should be the same as:

define( 'WP_CACHE_KEY_SALT', 'sitename:' );

Value right?


#10

Nope , As I said before the prefix defined by ‘define( 'WP_CACHE_KEY_SALT', 'sitename:' );’ is for Redis object-caching.

I hope I am clear enough .


#11

Ok, Thanks :smiley:


#12

The Redis Cache Prefix for page caching in the NGINX Helper plugin can be the same for all site syou have on a VPS, our must it be different per site? Currently this prefix is nginx-cache:, for all sites on my VPS. Is that okay? Or do I need to make the prefix unique per site? If this prefix does not need to be different per site, what would be the advantage (if any) of making the prefix different per site?


#13

Different per site is highly advisable.


#14

Why is that? What happens if they are the same vs different? Maybe this should also be done automatically by EE, just as it is now for the object cache.


#15

I don’t think that the page cache setting in nginx-helper has any effect whatsoever. You can set it to what you like, the page cache key is always set to:

nginx-cache:httpGET<your url>

as set out in the virtual host’s nginx config.

The object cache key is set in the wp-config.php file as dictated by the redis-cache plugin.

Also, when using HHVM, the redis page cache does not work at all unless you set:

fastcgi_param HTTP_ACCEPT_ENCODING "";


#16

Isn’t the use of HHVM also requires to specify client in wp-config.php?

define('WP_REDIS_CLIENT', 'hhvm');

I was using REDIS CACHE even before the --wpredis option was introduced to EE and w/o that line it wasn’t properly working.


#17

I have the same question that @ddelaey was asking above, because the plugin labels are confusing… it looks like we’re setting 2 different key values for the same Redis cache.

In the WP admin, I see 2 indicators of a cache key:

  1. In the Redis plugin settings (Settings > Redis), you see “Key Prefix” with the URL of your website listed. This is not editable on the WP admin side (but you can change it with the WP_CACHE_KEY_SALT definition in wp-config.php), it just shows you what it is.
    Screenshot: https://goo.gl/gWTjm0
  2. In the Nginx Helper plugin settings (Settings > Nginx Helper), you see an area “Redis Settings” with an editable text box labeled “prefix” with nginx-cache: entered there for you.
    Screenshot: https://goo.gl/y411i8

So what I gather is, the redis cache prefix is for redis cache, but the Nginx Helper redis cache prefix is for Fast-CGI? This is confusing however, because of how it is labeled. It looks like we’re setting 2 different keys for the redis cache.

If you check out the file /etc/nginx/common/redis.conf you see this on line 39:

set $key “nginx-cache:$scheme$request_method$host$request_uri”;

Which indicates that the prefix nginx-cache: above is correct, and that fastcgi cache is automatically appending the site URI to the cache key so that it will work with multiple domains on one server.

So I conclude that we should leave nginx-cache: the way it is on every site. But I will say once agin, it is confusing because the plugins make it look like we are setting 2 different keys for just the Redis cache.

Am I correct in this or totally missing the picture?


#18

@THORR

Let me explain the whole thing for you.

There are two types os cache configured while you use --wpredis option when creating site.

  1. Page Cache (which has key like this “nginx-cache:$scheme$request_method$host$request_uri”. Defined in NGINX configuration fo redis cache. /etc/nginx/conf/redis.conf)

  2. Object Cache (which is done at PHP level. )

Now the reason why WP_CACHE_KEY_SALT used in wp-config is to seperate object cache for multiple sites on same server (Otherwise there may be collision https://github.com/rtCamp/easyengine/issues/593).

As Nginx-Helper plugin is used to purge Page cache, So there needs to be provide Area from which you have to purge cache so nginx-cache: is predefined as its part of your page cache key.


#19

@harshadyeola

Thanks for explaining. I’d like to rephrase my question, because I already understand why WP_CACHE_KEY_SALT is used, and so forth. I sort of mixed my descriptions up with my question, so I’ll try to extract the main question here:

My real question is about the Nginx Helper plugin having a duplicate key setting (quoted from above):

  1. In the Redis plugin settings (Settings > Redis), you see “Key Prefix” with the URL of your website listed. This is not editable on the WP admin side (but you can change it with the WP_CACHE_KEY_SALT definition in wp-config.php), it just shows you what it is. Screenshot: https://goo.gl/gWTjm0
  2. In the Nginx Helper plugin settings (Settings > Nginx Helper), you see an area “Redis Settings” with an editable text box labeled “prefix” with nginx-cache: entered there for you. Screenshot: https://goo.gl/y411i8

Shouldn’t these areas be re-labeled to say “Object Cache Key” and “Page Cache Key”?


#20

Nice suggestion. :slight_smile:

We can’t make any changes to other plugin but we can definitely make this change. We can even call it “Redis Full Page Cache Key Prefix” to be more descriptive.