Hi @atoomic
Based on the code snippet you provided, it looks like you are correctly calling the wp_super_cache_enable() function to enable the plugin via the REST API.
However, it’s possible that the plugin settings are not being updated correctly due to a caching issue or a conflict with other plugins or custom code on your site. Here are a few things you can try to resolve the issue:
- Clear cache: Clear the cache on your site and try submitting the POST request again to see if the changes are reflected in the UI.
- Disable other caching plugins: If you have other caching plugins installed on your site, they may be conflicting with WP Super Cache. Disable any other caching plugins and try enabling WP Super Cache again via the REST API.
- Check for conflicts: If disabling other plugins does not resolve the issue, check for conflicts with your theme or custom code on your site. Try disabling your theme and any custom code and see if the plugin settings are updated correctly.
- Check error logs: Review the error logs on your site to see if there are any error messages related to WP Super Cache or the REST API. This can help you identify the source of the issue and troubleshoot it more effectively.
Thanks for your reply, I tested on a fresh installation of WordPress and the API call is working fine.
POST /wp-json/wp-super-cache/v1/settings
{ "easy": true } # or { "easy": false }
What I can notice is the first time I run the API to enable the plugin it flips the cache_enabled boolean and add a wp_cache_debug_username
--- a/wp-content/wp-cache-config.php
+++ b/wp-content/wp-cache-config.php
@@ -5,12 +5,13 @@ WP-Cache Config Sample File
See wp-cache.php for author details.
*/
+$wp_cache_debug_username = 'deadbeefdeadbeefdeadbeefdeadbeef';
$cache_time_interval = 600;
if ( ! defined('WPCACHEHOME') )
define( 'WPCACHEHOME', WP_CONTENT_DIR . "/plugins/wp-super-cache/" );
$cache_compression = 0; // Super cache compression
-$cache_enabled = false;
+$cache_enabled = true;
$super_cache_enabled = true;
$cache_max_time = 1800;
//$use_flock = true; // Set it true or false if you know what to use
Later when accessing the ‘/wp-admin/options-general.php?page=wpsupercache‘ page from a browser some additional values are added to the configuration file. I’m not sure if the plugin works fine without these variable being set?
$wp_cache_home_path = '/';
$wp_cache_slash_check = 1;
$cache_page_secret = 'deadbeefdeadbeefdeadbeefdeadbeef';
Note/ProTip: in order to get the WebAPI working correctly you need to setup redirection in your .htaccess
+++ b/.htaccess
@@ -0,0 +1,15 @@
+# BEGIN WordPress
+# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
+# dynamically generated, and should only be modified via WordPress filters.
+# Any changes to the directives between these markers will be overwritten.
+<IfModule mod_rewrite.c>
+RewriteEngine On
+RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+RewriteBase /
+RewriteRule ^index\.php$ - [L]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule . /index.php [L]
+</IfModule>
+
+# END WordPress#
Thanks with or without these answers, we can close this case.
Later when accessing the ‘/wp-admin/options-general.php?page=wpsupercache‘ page from a browser some additional values are added to the configuration file. I’m not sure if the plugin works fine without these variable being set?
The “wp_cache_debug_username” value added to the configuration file is used for debugging purposes and is not required for the plugin to function properly.