Plugin Directory

WP Super Cache

How do I know my blog is being cached?

View the source of any page on your site. When a page is first created, you'll see the text "Dynamic page generated in XXXX seconds." and "Cached page generated by WP-Super-Cache on YYYY-MM-DD HH:MM:SS" at the end of the source code. On reload, a cached page will show the same timestamp so wait a few seconds before checking. In "HALF-ON" mode, if you have compression enabled, the text "Compression = gzip" will be added. If compression is disabled and the page is served as a static html file, the text "super cache" will be added. The only other way to check if your cached file was served by PHP script or from the static cache is by looking at the HTTP headers. WP-Cache (PHP) cached pages will have the header "WP-Super-Cache: WP-Cache". I used the Live HTTP Headers extension for Firefox to examine the headers. You should also check your cache directory in wp-content/cache/supercache/hostname/ for static cache files.

Why is WP-Super-Cache better than WP-Cache?

This plugin is based on the excellent WP-Cache plugin and therefore brings all the benefits of that plugin to WordPress. On top of that it creates copies of every page that is accessed on a blog in a form that is quickly served by the web server. It's almost as quick as if the you had saved a page in your browser and uploaded it to replace your homepage.

Will comments and other dynamic parts of my blog update immediately?

Comments will show as soon as they are moderated, depending on the comment policy of the blog owner. Other dynamic elements on a page may not update unless they are written in Javascript, Flash, Java or another client side browser language. The plugin really produces static html pages. No PHP is executed when those pages are served. "Popularity Contest" is one such plugin that will not work. Plugins that show different content for mobile users will probaby not work either.

Will the Super Cache compression slow down my server?

No, it will do the opposite in fact. Super Cache files are compressed and stored that way so the heavy compression is done only once. These files are generally much smaller and are sent to a visitor's browser much more quickly than uncompressed html. As a result, your server spends less time talking over the network which saves CPU time and bandwidth, and can also serve the next request much more quickly.

How do I make certain parts of the page stay dynamic?

WP Super Cache retains the dynamic loading code of WP Cache but only works in "half on" mode.

There are two ways to do this, you can have functions that stay dynamic or you can include other files on every page load. To have a dynamic function in the cached PHP page use this syntax around the function:

<!--mfunc function_name( 'parameter', 'another_parameter' ) -->
<?php function_name( 'parameter', 'another_parameter' ) ?>
<!--/mfunc-->

The HTML comments around the mirrored PHP allow it to be executed in the static page. To include another file try this:

<!--mclude file.php-->
<?php include_once( ABSPATH . 'file.php' ); ?>
<!--/mclude-->

That will include file.php under the ABSPATH directory, which is the same as where your wp-config.php file is located.

Why doesn't WP UserOnline, Popularity Contest, WP Postratings or plugin X not work or update on my blog now?

This plugin caches entire pages but some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript/AJAX methods or the mfunc/mclude code described in the previous answer to update or display dynamic information.

Why doesn't the plugin cache requests by search engine bots by default?

Those bots usually only visit each page once and if the page is not popular there's no point creating a cache file that will sit idle on your server.

Why shouldn't I create a cache file of every page on my site?

Like the previous question, there's no point caching pages that won't be visited. The large number of cache files will slow down the garbage collection system as it attempts to check each file. It also causes problems for hosting companies. In the event of a disk failure on your server it may take much longer to check the files. Remember how long a scandisk or a fsck took on a large drive?

A category page is showing instead of my homepage

A tiny proportion of websites will have problems with the following configuration:

  1. Uses a static page for the front page.
  2. Uses /%category%/%postname%/ permalink structure.

Sometimes a category page is cached as the homepage of the site instead of the static page. I can't replicate the problem but a simple solution is to switch the plugin to half-on mode. For normal traffic you will see no difference in the speed of your site.

Why do I get warnings about caching from http://ismyblogworking.com/

"Your blog doesn't support client caching (no 304 response to If-modified-since)." "Your feed doesn't support caching (no 304 response to If-modified-since)"

Supercache doesn't support 304 header checks. This is caching done by your browser, not your server. It is a check your browser does to ask the server if an updated version of the current page is available. If not, it doesn't download the old version again. The page is still cached by your server, just not by the browsers of your visitors. WordPress doesn't support 304 caching either so you're not losing out. Try the Cacheability Engine at http://www.ircache.net/cgi-bin/cacheability.py or http://redbot.org/ for further analysis.

Troubleshooting

If things don't work when you installed the plugin here are a few things to check:

  1. Is wp-content writable by the web server?
  2. Is there a wp-content/wp-cache-config.php ? If not, copy the file wp-super-cache/wp-cache-config-sample.php to wp-content/wp-cache-config.php and make sure WPCACHEHOME points at the right place. "plugins" should be "mu-plugins" if you're using WordPress MU.
  3. Is there a wp-content/advanced-cache.php ? If not, then you must copy wp-super-cache/advanced-cache.php into wp-content/. You must edit the file and change the path so it points at the wp-super-cache folder.
  4. If pages are not cached at all, remove wp-content/advanced-cache.php and recreate it, following the advice above.
  5. Make sure the following line is in wp-config.php and it is ABOVE the "require_once(ABSPATH.'wp-settings.php');" line:

    define( 'WP_CACHE', true );
    
  6. Try the Settings->WP Super Cache page again and enable cache.
  7. Look in wp-content/cache/supercache/. Are there directories and files there?
  8. Anything in your php error_log?
  9. If your browser keeps asking you to save the file after the super cache is installed you must disable Super Cache compression. Go to the Settings->WP Super Cache page and disable it there.
  10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
  11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the Enforce www preference plugin if you are using an old WordPress install. The latest versions redirect themselves (you should always be running the latest version of WordPress anyway!)
  12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this discussion for more.
  13. File locking errors such as "failed to acquire key 0x152b: Permission denied in..." or "Page not cached by WP Super Cache. Could not get mutex lock." are a sign that you may have to use file locking. Edit wp-content/wp-cache-config.php and uncomment "$useflock = true" or set $semid to a different value. You can also disable file locking from the Admin screen as a last resort.
  14. Make sure cache/wpcachemutex.lock is writeable by the web server.
  15. The cache folder cannot be put on an NFS or Samba or NAS share. It has to be on a local disk. File locking and deleting expired files will not work properly unless the cache folder is on the local machine.
  16. Garbage collection of old cache files won't work if WordPress can't find wp-cron.php. If your hostname resolves to 127.0.0.1 it could be preventing the garbage collection from working. Check your access_logs for wp-cron.php entries. Do they return a 404 (file not found) or 200 code? If it's 404 or you don't see wp-cron.php anywhere WordPress may be looking for that script in the wrong place. You should speak to your server administator to correct this or edit /etc/hosts on Unix servers and remove the following line. Your hostname must resolve to the external IP address other servers on the network/Internet use. See http://yoast.com/wp-cron-issues/ for more.

    127.0.0.1 myhostname.com
    

    A line like "127.0.0.1 localhost localhost.localdomain" is ok.

  17. If old pages are being served to your visitors via the supercache, you may be missing Apache modules (or their equivalents if you don't use Apache). 3 modules are required: modmime, modheaders and mod_expires. The last two are especially important for making sure browsers load new versions of existing pages on your site.
  18. The error message, "WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed!" appears at the end of every page. Open the file wp-content/advanced-cache.php in your favourite editor. Is the path to wp-cache-phase1.php correct? If it is not the caching engine will not load.
  19. Caching doesn't work. The timestamp on my blog keeps changing when I reload. Check that the path in your .htaccess rules matches where the supercache directory is. You may have to hardcode it. Or use the plugin in Half-On mode.
  20. If supercache cache files are generated but not served, check the permissions on all your wp-content/cache/supercache folders (and each of wp-content cache and supercache folders) and wp-content/cache/.htaccess. If your PHP runs as a different user to Apache and permissions are strict Apache may not be able to read the PHP generated cache files. To fix you must add the following line to your wp-config.php (Add it above the WP_CACHE define.) Then clear your cache.

    umask( 0022 );
    

Download

FYI

Compatibility beta

Your Setup

Log in to vote.

The Consensus (5 reporting)

100%
0,1,0
100,1,1
100,1,1
0,1,0 0,1,0 100,1,1 100,6,6
0,1,0 0,1,0 96,50,48 100,1,1
100,8,8 100,5,5
80,5,4

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(390 ratings)