Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter atoomic

    (@atoomic)

    thanks for confirming this is a feature 🙂 and not a bug

    Thread Starter atoomic

    (@atoomic)

    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.

    Thread Starter atoomic

    (@atoomic)

    I was able to solve my issue using Application Password, and then using Basic Authentication to submit the request.

    Looks like the session cookie is not enough on a browser and you probably need a nonce id also. This is why it was not working from the browser using an authenticated user.

    How To Get An Application Password:

    As of 5.6, WordPress has shipped with Application Passwords, which can be generated from an Edit User page (wp-admin -> Users -> Edit User).

    Alternatively you can use the CLI to generate / refresh the app password
    https://developer.ww.wp.xz.cn/cli/commands/user/application-password/

    Then you can use it as described here
    https://developer.ww.wp.xz.cn/rest-api/using-the-rest-api/authentication/

    curl -k --user 'username:YourOneTimePass' https://your-domain.test/wp-json/wp-super-cache/v1/settings
Viewing 3 replies - 1 through 3 (of 3 total)