WordPress-APCu-Object-Cache icon indicating copy to clipboard operation
WordPress-APCu-Object-Cache copied to clipboard

documentation about WP_APCU_KEY_SALT

Open Cyrille37 opened this issue 5 years ago • 5 comments

Hello, Thank you for this extension that makes wordpress greener (and faster) !

I think the docu on WP_APCU_KEY_SALT is wrong because we need to define WP_APCU_KEY_SALT not only when sharing a wp-config.php but when we share a Php instance (mutualized php). Like with php-fpm, the APC memory is shared with all pools so we have to define a unique WP_APCU_KEY_SALT for each wordpress installation.

So the documentation may be : If you have more than one Wordpress installation which share the same Php you have to define a unique WP_APCU_KEY_SALT for each.

Thanks again and cheers :-) Cyrille37.

Cyrille37 avatar Jun 21 '20 08:06 Cyrille37

Hello. Is my comment wrong or confirmed ? Thanks & cheers

Cyrille37 avatar Feb 04 '21 09:02 Cyrille37

This has salt based on the ABSPATH of the site so WP_APCU_KEY_SALT is needed only if more than one WordPress site is using the same directory on the server.

matt-h avatar Dec 02 '21 18:12 matt-h

Yeah! Thanks, that's nice :-) But the README has to be updated, isn't it ? Best Regards.

Cyrille37 avatar Dec 03 '21 08:12 Cyrille37

So should we define something like define( 'WP_APCU_KEY_SALT', 'somethinghere' );, right?

kevin25 avatar Nov 04 '22 04:11 kevin25

And does it support WooCommerce?

kevin25 avatar Nov 04 '22 04:11 kevin25

where do I have to define the WP_APCU_KEY_SALT ? in object-cache.php or in a plugin? if i define it in a plugin, it would only be available once the plugin is loaded IOW plugins and other functions loaded before this plugin would not have the the constant.

docjojo avatar May 21 '24 13:05 docjojo

where do I have to define the WP_APCU_KEY_SALT ? in object-cache.php or in a plugin? if i define it in a plugin, it would only be available once the plugin is loaded IOW plugins and other functions loaded before this plugin would not have the the constant.

You would put it in your wp-config.php file.

matt-h avatar May 21 '24 13:05 matt-h

makes sense.

docjojo avatar May 21 '24 13:05 docjojo

WP_APCU_KEY_SALT is not required to be set anywhere. If you don't understand what it is for then you likely don't need it

l3rady avatar May 21 '24 13:05 l3rady

I see, in my case ABSPATH differs for multiple WP installation on the same machine, so WP_APCU_KEY_SALT is not required?

docjojo avatar May 21 '24 13:05 docjojo

Correct. It is only need in very rare edge cases when someone is running multiple WP sites from a single set of core WP files. I don't know of anyone that does this so the default WP_APCU_KEY_SALT is fine.

l3rady avatar May 21 '24 13:05 l3rady

thank you.

docjojo avatar May 21 '24 13:05 docjojo

sorry for asking again.

I have a machine with multiple WP installations. Each install is in it's own directory, so ABSPATH differ. But in object-cache.php WP_APCU_KEY_SALT is defined with "wp", not ABSPATH, so all installations are using the same salt, no?

Code says:

if (!defined('WP_APCU_KEY_SALT')) { /** * Set in config if you are using some sort of shared * config where ABSPATH is the same on all sites */ define('WP_APCU_KEY_SALT', 'wp'); }

docjojo avatar Jul 02 '24 08:07 docjojo

https://github.com/l3rady/object-cache-apcu/blob/main/object-cache.php#L1120

Key uniqueness is made from an md5 of abs path. As long as your ABSPATH differ between installs on the same machine the keys wont clash. WP_APCU_KEY_SALT only needs to be changed if all installations share the same physical set of WP files.

l3rady avatar Jul 02 '24 09:07 l3rady

THANK YOU!

docjojo avatar Jul 02 '24 09:07 docjojo