Manually Enable WordPress Caching

When you enable the SWIS page cache, it will automatically attempt to add the WP_CACHE constant to your wp-config.php file. On some sites this will fail, and you might need to manually add WP_CACHE to your config file. A typical wp-config.php file will look something like this:

<?php

/**
 * The base configuration for WordPress
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */

define( 'DB_NAME', 'test' );
define( 'DB_USER', 'test' );
define( 'DB_PASSWORD', 'wa3eof4hlHiasdfSEFsdhdh' );
define( 'DB_HOST', 'localhost' );

....

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
        define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

There will be other things like "auth keys" and "salts" and the like, but we want to add WP_CACHE near the top of the file like so:

<?php

define( 'WP_CACHE', true );

/**
 * The base configuration for WordPress
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */

define( 'DB_NAME', 'test' );
define( 'DB_USER', 'test' );
define( 'DB_PASSWORD', 'wa3eof4hlHiasdfSEFsdhdh' );
define( 'DB_HOST', 'localhost' );

....

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
        define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

There are two important things to be sure of:

  1. Do not put anything before the opening "PHP tag" of "<?php".
  2. Do not add anything at the bottom of the file, or anywhere after the line that says "That's all, stop editing!"

Typically, it's best to put it right after the opening PHP tag, so it's easy to find if you ever need to disable it for any reason.

Have other questions? Click the contact button below to send us an email and we'll be happy to help!

Still need help? Contact Us Contact Us