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.
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?
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 6 years, 9 months ago by
danielflippance. Reason: The code change was actually an addition, not a replacement
Cache location is set to: /home/myusername/public_html/web/app/cache/
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! 🙂