Back to Community

Resolving the 'WPCACHEHOME must be set in config file' Error in WP Super Cache

30 threads Sep 7, 2025 PluginWp super cache

Content

If you've encountered the frustrating "WPCACHEHOME must be set in config file" error after installing or updating the WP Super Cache plugin, you're not alone. This is a common configuration issue that can prevent the plugin from functioning correctly. This guide will explain why this error occurs and walk you through the most effective solutions to get your caching back on track.

Why This Error Occurs

WP Super Cache needs to know the location of its own files before WordPress fully loads to serve cached pages as quickly as possible. It uses a constant named WPCACHEHOME to define this absolute server path. The error appears when the plugin either cannot automatically add this line to your wp-config.php file or cannot verify that it exists in the correct location. Common causes include:

  • File permission issues preventing the plugin from writing to wp-config.php.
  • The WPCACHEHOME constant being placed in the wrong location within the config file.
  • A bug in older versions of the plugin that displayed this warning incorrectly even when the constant was set.
  • The wp-super-cache plugin directory being missing or empty.

How to Fix the "WPCACHEHOME must be set" Error

Solution 1: Manually Define WPCACHEHOME in wp-config.php (Most Common Fix)

The most reliable solution is to manually add the required code to your WordPress configuration file.

  1. Connect to your website using FTP or your hosting provider's file manager.
  2. Locate and download the wp-config.php file in your site's root directory.
  3. Open the file in a text editor and find the line that says: require_once(ABSPATH . 'wp-settings.php');
  4. Above this line, add the following code, replacing the path with the absolute path to your WP Super Cache plugin directory:
    define( 'WPCACHEHOME', '/your/full/server/path/to/wp-content/plugins/wp-super-cache/' );
    Important: The path must be the full server path, not a URL. You can often find this path in your hosting control panel or by asking your host.
  5. Save the file and upload it back to your server, overwriting the old one.
  6. Refresh your WordPress admin dashboard. The error should now be resolved.

Solution 2: Check File and Directory Permissions

If manual editing doesn't work, file permissions may be the culprit. The web server (e.g., the user account running Apache or Nginx) needs permission to write to certain files.

  • Temporarily set permissions on the wp-content directory to 755 (or 775 if 755 doesn't work). You can do this via FTP or your host's file manager.
  • Ensure the wp-super-cache plugin directory exists and is not empty. If it is, reinstall the plugin.
  • After the plugin successfully generates the necessary files (advanced-cache.php and wp-cache-config.php), it is recommended to set their permissions to 600 for security, which is generally sufficient.

Solution 3: Update the Plugin

Some older versions of WP Super Cache had a known bug where this warning message was displayed incorrectly even when the WPCACHEHOME constant was properly set. As referenced in the sample threads, this was fixed in version 1.6.6. Ensure your plugin is updated to the latest version to eliminate this false positive.

Solution 4: For Developers and Staging Environments

If you move your site between different environments (e.g., staging to live) and don't want a hard-coded path, you can define WPCACHEHOME dynamically using server variables. Furthermore, to prevent WP Super Cache from trying to edit your wp-config.php file and causing permission conflicts, add the following filter to your theme's functions.php file or a must-use plugin:

add_filter( 'wpsc_enable_wp_config_edit', '__return_false' );

What If You Can't Edit wp-config.php?

Some managed hosting providers lock down the wp-config.php file. If this is the case, your options are more limited. You can try defining the constant very early in the loading process using a must-use plugin. Create a file in wp-content/mu-plugins/ (create the directory if it doesn't exist), for example, define-wpcachehome.php, and add this code:

<?php
// Define WPCACHEHOME for WP Super Cache
define( 'WPCACHEHOME', '\app\public\wp-content\plugins\wp-super-cache/' );

Note that success with this method can vary depending on your host's specific setup.

By following these steps, you should be able to resolve the "WPCACHEHOME must be set" error and configure WP Super Cache successfully. If problems persist, enabling the debug log from the plugin's Debugging page can provide more detailed clues about the underlying issue.

Related Support Threads Support