pj-object-cache-red icon indicating copy to clipboard operation
pj-object-cache-red copied to clipboard

Using common config

Open dingman opened this issue 5 years ago • 5 comments

Great plugin, thank you so much for it.

I am wondering if you would be willing to support a common config between the object cache and the page cache plugins? Or maybe it already exists and I didn't see it

This is my current config to support both

$redis_page_cache_config = array();

// Change the cache time-to-live to 10 minutes
$redis_page_cache_config['ttl'] = 600;
$redis_page_cache_config['redis_host'] = 'xxxxxxxxxx.amazonaws.com';
$redis_page_cache_config['debug_data'] = true;
// Ignore/strip these cookies from any request to increase cachability.
//$redis_page_cache_config['ignore_cookies'] = array( 'wordpress_test_cookie', 'openstat_ref' );
$redis_page_cache_config['whitelist_cookies'] = array( 'test' );

// Ignore/strip these query variables to increase cachability.
//$redis_page_cache_config['ignore_request_keys'] = array( 'utm_source', 'utm_medium', );

// Vary the cache buckets depending on the results of a function call.
// For example, if you have any mobile plugins, you may wish to serve
// all mobile requests from a different cache bucket:


define('WP_REDIS_BACKEND_HOST', $redis_page_cache_config['redis_host'] );

dingman avatar May 13 '20 15:05 dingman

There is no API compatibility between the two plugins, because the object cache plugin is a hard fork of an existing solution. We would like to maintain backward compatibility with it, so that people can just plugin n' play and switch out anytime.

But you idea is interesting. We can probably come up with something if more people need this. You're welcome to submit a patch as well.

Leaving open for consideration.

soulseekah avatar May 13 '20 15:05 soulseekah

One idea is on the page cache plugin, to check if WP_REDIS_BACKEND_HOST is already set and if it is set, use that value instead of only the $redis_page_cache_config[] array for settings.

Thoughts?

dingman avatar May 13 '20 16:05 dingman

It should be one of the default fallbacks in the configuration parser. If it's not explicitly set then check the WP_REDIS_BACKEND_HOST. Would you like to write the patch for this?

soulseekah avatar May 13 '20 16:05 soulseekah

@soulseekah I appreciate the vote of confidence in me. I looked at the code and I'm not seeing the most appropriate way to patch it. Please do feel free to go ahead and patch it the correct way to the standards.

dingman avatar May 14 '20 02:05 dingman

I read through the code again and proposed the change. Thanks!

dingman avatar May 14 '20 03:05 dingman