Title: Enabling SuperCache using RestAPI
Last modified: March 17, 2023

---

# Enabling SuperCache using RestAPI

 *  Resolved [atoomic](https://wordpress.org/support/users/atoomic/)
 * (@atoomic)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/enabling-supercache-using-restapi/)
 * Hi I’m using the RestAPI to enable SuperCache.
 * I m submitting a POST request to /wp-json/wp-super-cache/v1/settings URL with
   the data “{ easy => true }”
 *     ```wp-block-code
       POST /wp-json/wp-super-cache/v1/settings 
       { "easy": true }
       ```
   
 * After adding some debug to the /class.wp-super-cache-rest-update-settings.php
   file I can confirm that the toggle_easy_caching function is called and that “
   wp_super_cache_enable();” is also called
 *     ```wp-block-code
              protected function toggle_easy_caching( $enabled = true ) {
                       global $cache_path, $wp_cache_shutdown_gc, $cache_schedule_type;
                       if ( $enabled ) {
                               // return rest_ensure_response( array( "easy" => "enabling it...." ) );
                               $settings = array(
                                       'wp_cache_mobile_enabled' => 1,
                                       'is_cache_enabled'        => 1,
                                       'cache_rebuild_files'     => 1,
                                       'cache_compression'       => 0,
                                       'wp_cache_not_logged_in'  => 2,
                               );
                               wp_cache_enable();
                               //return rest_ensure_response( array( "easy" => "463" ) );
                               if ( ! defined( 'DISABLE_SUPERCACHE' ) ) {
                                       return rest_ensure_response( array( "easy" => "465" ) );
                                       wp_cache_debug( 'DISABLE_SUPERCACHE is not set, super_cache enabled.' );
                                       wp_super_cache_enable();
                               }
                               wpsc_set_default_gc();
   
                       }
       ```
   
 * But when going back to the wp-admin UI the radio is still set to “Caching Off”.
   What am I missing? What additional steps need to be performed to enable the plugin
   using the API?
 * The API reply contains the following fields:
 *     ```wp-block-code
       ...
       # is_cache_enabled => 1
       # is_super_cache_enabled => 1
       ...
       ```
   
 * Note: I double checked that DISABLE_SUPERCACHE was not set.
    -  This topic was modified 3 years, 2 months ago by [atoomic](https://wordpress.org/support/users/atoomic/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fenabling-supercache-using-restapi%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Bruce (a11n)](https://wordpress.org/support/users/bruceallen/)
 * (@bruceallen)
 * Happiness Engineer
 * [3 years, 2 months ago](https://wordpress.org/support/topic/enabling-supercache-using-restapi/#post-16572280)
 * Hi [@atoomic](https://wordpress.org/support/users/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:
    1. 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.
    2. 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.
    3. 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.
    4. 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.
 *  Thread Starter [atoomic](https://wordpress.org/support/users/atoomic/)
 * (@atoomic)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/enabling-supercache-using-restapi/#post-16593094)
 * Thanks for your reply, I tested on a fresh installation of WordPress and the 
   API call is working fine.
 *     ```wp-block-code
       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
 *     ```wp-block-code
       --- 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-block-code
       $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
 *     ```wp-block-code
       +++ 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.
 *  [Bruce (a11n)](https://wordpress.org/support/users/bruceallen/)
 * (@bruceallen)
 * Happiness Engineer
 * [3 years, 2 months ago](https://wordpress.org/support/topic/enabling-supercache-using-restapi/#post-16603225)
 * > 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.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Enabling SuperCache using RestAPI’ is closed to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [rest](https://wordpress.org/support/topic-tag/rest/)

 * 3 replies
 * 2 participants
 * Last reply from: [Bruce (a11n)](https://wordpress.org/support/users/bruceallen/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/enabling-supercache-using-restapi/#post-16603225)
 * Status: resolved