October 4th in WordPress by charlie .

Correct WP Super Cache Settings Fix CPU Spikes

WP Super Cache is one of the MOST indispensable WordPress plugins you can find. It’s usually quite easy to set up and dramatically reduces the work your server performs to serve your content.

  • Twitter
  • Facebook
  • StumbleUpon
  • Technorati Favorites
  • FriendFeed
  • Delicious
  • LinkedIn
  • Yahoo Buzz
  • Yahoo Bookmarks
  • Google Bookmarks
  • Share/Bookmark

I just completed upgrading my web hosting services for 2 blogs because of huge CPU spikes. These 2 blogs are only doing 10k-15k pageviews per day. So really, there’s no reason for CPU spikes.

Except I didn’t have correct WP Super Cache settings.

I’m relentless about checking settings, watching traffic, updating plugins and all that, but the problems I experienced were strange and seemingly unsolvable.

I stay current on WordPress.org forums and other expert sites, and I’m the first to Google a problem to learn about and resolve problems. I haven’t seen this information anywhere else.

Here’s how I solved my WP Super Cache problems.

Setting Up WP Super Cache

What is WP Super Cache?

WP Super Cache is a WordPress plugin that was developed by Donncha O Caoimh, an Irish WordPress developer extraordinaire and WordPress folk hero. WP Super Cache generates HTML files without invoking the PHP engine. The HTML files are saved to a directory structure within the /wp-content/cache folder and are served by Apache just about as fast and with as much resource load on your server as image files.

WP Super Cache dramatically reduces a server’s CPU load.

Here’s a graph of a dual XEON CPUs on a VPS hosting 2 WordPress blogs with bad WP Super Cache settings. Note how both CPUs spike to 100%.

2 Xeon Quad Core Cpus Spiking To 100 Percent

2 Xeon Quad Core CPUs Spiking To 100 Percent

Here’s a graph of the CPUs after upgrading to 4 CPUs, but with CORRECT WP Super Cache settings. Four CPUs, yes, but note how there is no spiking.

4 Xeon Quad Core CPUs Not Spiking WP Cache Settings Correct

4 Xeon Quad Core CPUs Not Spiking WP Cache Settings Correct

Correct WP Super Cache Settings

Here’s how I set up WP Super Cache the right way.

First, install the WP Super Cache plugin and the Bad Behavior plugin.

Second, go to the WP Super Cache settings screen. Select ‘ON’, ‘Cache Rebuild’ and ‘Mobile Device Support’ as you see in the screen shot.

Best WP Super Cache Settings

Best WP Super Cache Settings

Third, check your Mod Rewrite rules. If you haven’t applied them you’ll need to.

WP Super Cache Mod Rewrite SettingsWP Super Cache Mod Rewrite Settings

WP Super Cache Mod Rewrite SettingsWP Super Cache Mod Rewrite Settings

As you’re going through setup, WP Super Cache tells you what you need to do to enable it. It will tell you that you need to make /wp-content/cache writable, and will then tell you to make /wp-content/wp-cache-config.php writable with CHMOD 666 settings.

The Secret WP Super Cache Settings

You can Google everything about WP Super Cache, but some things you’ll just never find.

Like this.

First, WP Super Cache contains two files that it apparently copies over to your /WP-Content folder on install – advanced-cache.php and wp-cache-config.php. If the plugin fails to copy the files over, or if the files become corrupt somehow, you’ll need to manually move these files over via FTP or file management.

Second, on my sites the plugin wasn’t able to determine the path to the /wp-content/cache/supercache folder. I had to edit advanced-cache.php and hardcode the full server path into the “if ( !include_once(“  and “if ( !@is_file(” lines. (By full server path, I mean from the root of my hosting account, not just from the root of my site.)

Examples of Correct WP Super Cache Settings

WP Super Cache is configured correctly if Cache Contents in the WP Super Cache admin screen displays counts and file sizes of cached and expired pages.

WP Super Cache File Counts And Sizes

WP Super Cache File Counts And Sizes

You can also verify that the plugin is working via your FTP tool. Just FTP in and check your /wp-content/cache directory.

WP Super Cache Site Cache

WP Super Cache Site Cache

Oh, one last thing. I have a bunch of WordPress blogs under management. One error I can’t seem to overcome is the Bad Behavior display. I’m fine if Bad Behavior tells me there’s a problem if all the settings above are good to go.

Bad Behavior Annoying Bogus Error Message

Bad Behavior Annoying Bogus Error Message

charlie

Hey, thanks for stopping by! Please take a few moments to comment on this topic and let me know how I'm doing.

3 Comments

  • Donncha
    October 5, 2009
  • Linux And Friends
    December 24, 2009
    • charlie
      December 24, 2009

Leave A Comment.