• I’m using the Roots Bedrock WP project framework and would like to use WP Super Cache with it.
    Bedrock changes the folder hierarchy to the structure shown below, and this seems to break WP Super Cache. I tweaked a couple of lines to get the caching to work but the Preload feature doesn’t work so even if I manually hit all the pages, the cache is lost after expiration and not re-loaded by Preload.

    Can you give any advice about how I might change the code in order to get it to work with this folder structure?

    ├── composer.json
    ├── config
    │ ├── application.php
    │ └── environments
    │ ├── development.php
    │ ├── staging.php
    │ └── production.php
    ├── vendor
    └── web
    ├── app
    │ ├── mu-plugins
    │ ├── plugins
    │ ├── themes
    │ └── uploads
    ├── wp-config.php
    ├── index.php
    └── wp

Viewing 6 replies - 1 through 6 (of 6 total)
  • Have you tried setting the “Cache Location” on the advanced settings page to where your cache directory is? Other than that, I can’t think of anything that would change.

    Thread Starter danielflippance

    (@danielflippance)

    Yes, I’ve done that. The cache works but the preload does not.

    define('WPCACHEHOME', '/Users/myuser/myproject/web/app/plugins/wp-super-cache

    To get the cache to work I had to modify line 631 of the file web/app/plugins/wp-super-cache/wp-cache-phase2.php as follows:

    
        //$site_url = site_url();
        //In Bedrock, site_url() returns www.domain.com/wp
        //See https://github.com/pressbooks/pressbooks/pull/971
        $site_url = home_url();
    

    Perhaps there is a similar change I need to make in the preload code?

    Thread Starter danielflippance

    (@danielflippance)

    I also had to add these lines at the top of web/app/wp-cache-config.php:

    
    //Make it work with Bedrock
    //$wp_cache_home_path = '/wp/';
    if (defined('ABSPATH')) {
        $wp_cache_home_path = ABSPATH;
    } else {
        $wp_cache_home_path = '/wp/';
    }
    
    $wp_cache_slash_check = 1;
    
    • This reply was modified 5 years, 7 months ago by danielflippance. Reason: The code change was actually an addition, not a replacement
    Thread Starter danielflippance

    (@danielflippance)

    Cache location is set to: /home/myusername/public_html/web/app/cache/

    Thread Starter danielflippance

    (@danielflippance)

    To get the debug log viewer to work in Bedrock, I had to make the following 2 changes:

    config/application.php:

    
    define('BEDROCK_WEBROOT', dirname(__DIR__) . '/web');
    

    web/app/plugins/wp-super-cache/wp-cache.php line 2128:

    
    // $log_file_link = "<a href='" . site_url( str_replace( ABSPATH, '', "{$cache_path}view_{$wp_cache_debug_log}?wp-admin=1&wp-json=1&filter=" ) ) . "'>$wp_cache_debug_log</a>";
    if (defined('BEDROCK_WEBROOT')) {
    	$log_file_link = "<a href='" . home_url( str_replace( BEDROCK_WEBROOT, '', "{$cache_path}view_{$wp_cache_debug_log}?wp-admin=1&wp-json=1&filter=" ) ) . "'>$wp_cache_debug_log</a>";
    } else {
    	$log_file_link = "<a href='" . site_url( str_replace( ABSPATH, '', "{$cache_path}view_{$wp_cache_debug_log}?wp-admin=1&wp-json=1&filter=" ) ) . "'>$wp_cache_debug_log</a>";
    }
    

    @danielflippance aren’t all these changes a bit much? What about when you want to update the plugin or WP or both? You’ll do the changes manually again?

    That said, I’d love to have WP Super Cache working with Bedrock too, but without manual hacking around, since it’s not really a neat approach when using proper development like CI, deployments, GIT, etc.

    Hope you manage to solve it with @donncha without too much hacking, and do let me know if you do! ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Use with Roots Bedrock’ is closed to new replies.