wp-super-cache-cli icon indicating copy to clipboard operation
wp-super-cache-cli copied to clipboard

Super cache configuration export/ import

Open Ontario7 opened this issue 6 years ago • 1 comments

The question is how to save WP Super Cache plugin configuration while deploy a new version of the web.

We have two domains: example.com (deploy) - with caching on dev.example.com (dev version) - with WPSC plugin turned off

While new deploy we use the bash script so the full process gets ~2 minutes

Problem is that after deployment we have to restore WPSC settings manually and its a bit terrible. We can not use saved wp-cache-config.php file because $cache_page_secret constant is unique.

Is there any way to save and restore the configuration?

Wp-cli has no option to do it for now. Could be:

wp super-cache export-settings >file

wp super-cache import-settings <file

So during deploy could be the sequence:

wp plugin activate wp-super-cache wp super-cache enable wp super-cache flush wp super-cache import-settings <file

It would be really great!

Ontario7 avatar Jan 19 '20 12:01 Ontario7

Reviewed the code involved, the secret in this case is simply this just this: md5( date( 'H:i:s' ) . mt_rand() );

You could execute that code & dump your own secret to the file. Should prove straightforward, thanks! Something like this: cache_page_secret=$(php -r 'echo md5( date( "H:i:s" ) . mt_rand() );')

markallasread avatar Aug 08 '23 21:08 markallasread