WP Super Cache 0.8

WP Super Cache is a page caching plugin for WordPress that will significantly speed up your website.

If you’re not interested in the changes, simply grab the latest version of the plugin and copy the files into your plugin folder. It’ll work, but if you’re upgrading, you should read on.

Major changes in this release:

  1. Generate a semaphore id based on hostname and cache path to avoid problems on shared hosts, props Tigertech.
  2. If you run WordPress from a different directory to where it’s installed, supercached files weren’t deleted when a post was made or updated. That is now fixed. Thanks Viper007Bond for all your help on that.
  3. Paged archives, category pages, and tag pages are now cleared when a post is edited or comment approved. This replicates what WP Cache did all along so you should hopefully see supercached static files updating more often.
  4. If your .htaccess is read-only, the mod_rewrite rules are displayed on the admin page. Thanks Matt for the patch.
  5. Updated mod_rewrite rules won’t serve static html files if there’s a “=” in the url. Should catch all sorts of problems with plugins and attachments. You’ll have to manually edit your root .htaccess to match the new rules.
  6. Set cache control and expiry headers of supercached files. They are cached for 5 minutes, but with a “must-revalidate” header. Delete wp-content/cache/.htaccess for the new rules to be updated.
  7. Check for WordPress MU because it can’t update the .htaccess file.
  8. Write supercache html to temporary files and rename. The old way opened the correct file for writing, did some work and wrote the file. In the fraction of a second it took to write the file, someone might request it and get an incomplete page.
  9. The Supercache expiry time has been removed. There can be only one.

Edit: 0.8.1 has just been released. This addresses the following:

  • The “forbidden files” problems some users had is fixed.
  • Supercache files were being removed needlessly when a moderated comment was made.
  • I added a “Clear cached files when post is edited” checkbox.
  • I added a “Delete Cache” link next to the Dashboard link on the dashboard.
  • Tigertech found that when a file is renamed and the new filename is already used, the old remains.
  • Updated readme.txt.

You might also like

If you like this post then please subscribe to my full RSS feed. You can also click here to subscribe by email. There are also my fabulous photos to explore too!

Published by

Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Google+ and Twitter.

55 thoughts on “WP Super Cache 0.8”


  1. Hi
    another lovely release. Simply love your plugin I believe that it should be built into wordpress. Its a lifesaver.

    Thanks again.

    Just thought of letting you know, my previous version of SuperCache (0.7.1) is not showing any new updates for it (maybe its not updated in the WP plugins repository).


  2. What I would love in this plugin is an action that I can pass a URL (or regex pattern for a more advanced version) to and it will expire or delete the cache for that/them page(s).

    Then I can call the “expire” action from a plugin that I know is going to modify the content on a particular page.


  3. Joel – WordPress probably hasn’t checked the repository yet. It usually does it twice a day.

    Barry – fancy submitting a patch? “Scratch that itch” you know!


  4. hello,

    just upgraded the plugin to version 0.8….now big problem, when i go to a cached page i have the message for example (it is the same with all the supercached page) :
    Forbidden
    You don’t have permission to access /wp-content/cache/supercache/www.neomansland.info/2008/09/le-fauteuil-poubelle//index.html on this server.

    I’ve been to see the permission of the file index.html for these pages and it is at 600 instead of at least 644 for people to have the ability to read the file.
    I’m using WP-super cache since a long time and always update it with the process indicated in the wordpress plugin page. IT was working nice with previous version 0.7.1.
    IS that a bug of this new version ? or is there something i missed during the upgrade process ?
    thanks a lot.


  5. Computer Aid – there was no need for it, and now that the plugin is more aggressive about clearing out of date cache files it doesn’t make sense any more. It also confused people why it was there in the first place!


  6. Neokentin – that’s odd. Have you tried clearing the cache? There were no changes to permissions that would cause that to happen.

    Who owns the file? Did your webhost change something today? Apache creates the files so it should be able to read it too.


  7. ok i’ve try what you tell me, i clear the cache. it seems to work now but there is a strange thing that happen.
    I use http://tools.pingdom.com/ in order to check the loading speed of my blog. Before version 0.8 of wp super cache, everything was fine, it told me the speed to oad my blog. Now when i enter my address it told me :
    URL doesn’t exist: http://www.neomansland.info

    For the permissions, user get the permission to read and write, then groups have no permissions and other none too.

    My webhost don’t change nothing today has it was working before upgrade of wp super cache, the problem appears when installing 0.8 … or maybe my webhost has changed something just at this moment but i don’t think so.

    thanks for your help.


  8. i forgot to told that for the autorizations it is only for the files inside the folder supercache.
    For the others wp-cache-xxxxxxxx.html the permissions are :
    user : read – write
    groups : read
    others : read

    I’ve came back to version 0.7.1, now files that are in the folder supercache have these permissions :
    user : read-write
    groups : read
    others : read

    there is something with version 0.8 that remove the permissions of reading of groups and others…resulting in the forbidden message.
    Also i redo the test with pingdom tools and now my url is accessible….

    Hop this can help.
    thanks


  9. Something is horribly wrong with this version. The new supercache rules completely horked my site and I had to remove them to make it work again.

    These are the rules it gave me. They absolutely do not work.


    # BEGIN WPSuperCache

    RewriteEngine On
    RewriteBase /blog/
    AddDefaultCharset UTF-8
    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/cache/supercache/%{HTTP_HOST}/blog/$1/index.html.gz -f
    RewriteRule ^(.*) /blog/wp-content/cache/supercache/%{HTTP_HOST}/blog/$1/index.html.gz [L]

    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/cache/supercache/%{HTTP_HOST}/blog/$1/index.html -f
    RewriteRule ^(.*) /blog/wp-content/cache/supercache/%{HTTP_HOST}/blog/$1/index.html [L]

    # END WPSuperCache


  10. Okay, I don’t know what went wrong where, bu 0.8 completely killed my site. Pages would no longer load unless I was logged in (some kind of weird extreme delay issue that I can’t work out.. pages simply never finished building and never returned anything), the new rewrite rules don’t work at all (resulting in page not found errors), etc.

    Reverting to 0.7.1 and clearing the cache fixed it more or less instantly.


  11. Otto – Thanks, can you email me your current (0.7.1) mod_rewrite rules? Please, what’s the value of get_option( ‘home’ ) and siteurl? Email is donncha @ ocaoimh.ie


  12. @Donncha: I experienced the exact same issues as Neokentin. At the moment I have switched to Half On but it looks like 0.8 is mucking up the group and world read permissions. I had to clear my cache and drop back to half on to avoid forbidden page errors.


  13. Great plugin. I am using this plugin from last 6 months.

    I am facing problem loading the admin pages and sometimes even the wordpress blog. It gives 505 errors. Not sure whether it has to do with this plugin or my host.


  14. Mellow, Otto – I think I know what’s happening. I’m guessing that Apache is running as a different user to php on your hosts. Somehow the “write to temporary file and rename it” process changes the username in a way that writing to the original file did not do. I’ll add a chmod to make the files world readable.


  15. “Showbiz – are you sure? You should set the garbage collection value higher, perhaps to 5000 so it doesn’t check as often.”

    hi donncha (sounds like pussycat dolls to me,lol..just kidding!)

    i found the garbage collection in the code and deleted the 1000 and 2000 thingies and just saved the 5000. is that the correct way to do as per your reply? thanks


  16. Showbiz – well, you could have just selected “5000” from the admin page without hacking any code, but that’s right.

    Mellow – can you check who owns the supercache files? Is it the same user that owns the files in wp-content/cache/ (the wp-cache html files)?


  17. OK, I have it nailed down, tagging release 0.8.1 in a few minutes with fixes for the permission denied bug and another bug where cache files are removed when a moderated comment is made.


  18. hi, i tried this great plugin lots of time, but never used! it always cached 0 pages. Could you explain “You should have mod mime, mod rewrite and fancy permalinks enabled”? I use permalink structure. PHP Safe mod disabled.


  19. Okay, so I tried out the new 0.8 rewrite rules with the 0.7.1 code, and it works without problems. So that part is fine, it must be the permissions thing that you’re talking about instead.


  20. Hi Donncha, This is great.

    But I still need your help over this one ISSUE:

    – Over WPMU I have setup many blogs and sites. IF I enable WP Super Cache on one blog, the entire sites and blogs shall have WP Super Cache enabled. The same goes for disable.

    – The only option now is to deactivate the plugin on the blogs which I don’t want to be cached.

    – I wish Super Cache use some different mechanism to control this. Otherwise I will just have to stick with WP Cache, or none.

    Thanks again, and wish things work out. Please email me if you do respond to my comment. I don’t subscribe because I know a lot of people will write.


  21. Binh – the best thing you could do (and I think I said this on the forum too) is to hack wp-cache-config.php and exclude the or include the blogs you want cached or not.
    There’s already code in there for identifying individual blogs so it should be easy to hardcode an array of blogs you don’t want cached and then set $cache_enabled to false.


  22. Binh – the best thing you could do (and I think I said this on the forum too) is to hack wp-cache-config.php and exclude the or include the blogs you want cached or not.

    Absolutely.

    Even easier, is an array in wp-config of matching http_hosts. If the current host matches, define the cache constant as true.

    Makes it easier for upgrades, too.

    Typically, on an average MU site, you’re only going to want to cache a handful of really active blogs, so this works out very well.


  23. Hi Donncha!
    Thanks for great plugin, it`s very helpful for me. But I slightly hack it.
    I use Super Cache to PRE-fitch pages with cron to human. My cheap VDS is very, very slow – 300 Mhz, 128 Mb.
    When I wont to collect RSS-feed (./news/) with SimplePie from 20-30 feed and re-arrange field at date it took about 30-40-60 second. Terrible lag!
    I dont understood php for make something new, but I can to break something existing.
    So, I change part of code on file advanced-cache, where
    “$key = $blogcacheid . md5($_SERVER[‘HTTP_HOST’].preg_replace(‘/#.*$/’, ”, str_replace( ‘/index.php’, ‘/’, $_SERVER[‘REQUEST_URI’] ) ).$wp_cache_gzip_encoding.wp_cache_get_cookies_values());

    to
    “function key_managment(){
    if(preg_match(“/\/news\//”,$_SERVER[‘REQUEST_URI’]))
    {
    $key = $blogcacheid .md5($_SERVER[‘HTTP_HOST’].preg_replace(‘/#.*$/’, ”, str_replace( ‘/index.php’, ‘/’, $_SERVER[‘REQUEST_URI’])));

    }
    else
    {
    $key = $blogcacheid . md5($_SERVER[‘HTTP_HOST’].preg_replace(‘/#.*$/’, ”, str_replace( ‘/index.php’, ‘/’, $_SERVER[‘REQUEST_URI’] ) ).$wp_cache_gzip_encoding.wp_cache_get_cookies_values());

    }
    return $key;
    }

    $key = key_managment(); ”

    also I add in
    “$wp_start_time = microtime();
    if( ($mtime = @filemtime($meta_pathname)) ) {
    if ($mtime + $cache_max_time > time() || !preg_match(“/^curl/”,$_SERVER[‘HTTP_USER_AGENT’]) ) {
    $meta = new CacheMeta;”
    verify client for caching with cron only

    and modify
    “function wp_cache_get_cookies_values($var1) {
    if($var1!=”/^wordpress_logged_in/”) $var1=”/^wp-postpass|^wordpress|^comment_author_/”;
    $string = ”;
    while ($key = key($_COOKIE)) {
    if (preg_match($var1, $key)) {
    $string .= $_COOKIE[$key] . “,”;”
    to prevent caching logged user (it seems…)

    Then I set cache time to 19 minute and cron time to 20 minute, and it work`s well!

    So, is it possible to include something liking that to original plugin? I mean include option to cache some pages with time to live at one side and single named this pages for everyone, avoid mix name with cookies or something else, at another side.
    I understand very well – its hole at security, but think sometime its useful.

    PS. Sorry for my English – I`am from Russia and learning in school hmm…. so-so :)


  24. I just checked in some experimental code that keeps copies of supercached files around after a comment is made so that anonymous users will see a slightly out of date cached file for a few seconds, but it should help a LOT on sites that receive lots of comments.

    ‘Course, I’m not sure if it’s worth it because the extra code does a lot of file checking and smaller sites won’t see any speedup. It might even slow down the site (slightly) for logged in users.

    If you’re curious, give it a go by downloading the development version from http://wordpress.org/extend/plugins/wp-super-cache/download/ or using Subversion to get it from http://svn.wp-plugins.org/wp-super-cache/trunk


  25. Hello! Thanks for a great plugin! I’m having an issue with the plugin caching some of my template files, even though I have included them in the ‘Do not cache’ section. For example, I have a template file, home.php, that is being displayed on my root/index page /. However, this page is still being cached. Is there some PHP I can put in my template file that will prevent it from being cached? Thanks.


  26. Thanks for the great plugin Donncha!
    I’ve using this nice plugin since 0.6.7 and running without problem.

    But after upgraded to 0.8/0.8.1, my site is facing a problem that when an new post is made or an old post is edited, all cached and expired files for posts/tags/categories/paged under WP Cache and WP Super Cache were deleted (folders remain here but html files inside are deleted, the cache of pages remain here).

    Is it the design of 0.8 that all posts/tags/categories/paged would delete when post change? Or just for that specific post, related tags and categories to be deleted when post change?

    Since my site is quite busy site, so if every time make an new post or edit an old post would cause all cached and expired files clear, the server loading would increase rapidly.

    So just want to check if it’s the problem on my own or it’s the original design of 0.8.

    Thanks!


  27. Brian – Did you enable the “clear all cache when post is edited” option? Unfortunately you can’t turn that off unless you edit wp-content/wp-cache-config.php
    Also I discovered that the “edit_post” action is activated when a comment is left, thus clearing the cache as well which is definitely not what we want to happen!

    The newest version follows more closely what wp-cache does – it deletes the cache file for the post plus deletes some other “non post” pages that seem to be related, although from testing they’re not always so.

    Casey – you need to specify the urls, not the template files.


  28. Donncha thanks for the reply.

    I didn’t enable the “clear all cache when post is edited”. So there is no $wp_cache_clear_on_post_edit in my wp-content/wp-cache-config.php

    With the concept you explained, may be I know what is happening to me… Most of my posts (95%) didn’t fill with content, instead numerous custom field values (metadata). As a result, those posts didn’t fill with content are considered as related, thus when a post is edited or made, nearly all of my cached and expired files are deleted. It is correct for my case?


  29. Hi,
    is there any way to get statistics for the blog without using external services like google analytics or wordpress stats? e.g. Cystats is failing…

    Greetings from Germany!
    Uli


  30. I have been using wp-super-cache for quite a while on several sites and really like it, but with version 0.8.4 on one of my sites (http://www.northcarolinagenealogy.net) it seems to be throwing up a 403 Forbidden that says

    Forbidden
    You don’t have permission to access /wp-content/cache/supercache/www.northcarolinagenealogy.net//index.html on this server.
    Apache/2.0.52 (Red Hat) Server at http://www.northcarolinagenealogy.net Port 80

    I checked the file permissions and there is no index.html file. This is with the .htaccess rules added to the .htaccess file. If I take out and use the wordpress default .htaccess all works. If I’m logged in I don’t have any issue.

    Strangely I don’t seem to have the same problem with the other sites I use it on (same version of super cache). Clearing the cache works for the first dynamic page load, but the second fails with the same forbidden error.


  31. As a second note – I’ve just discovered a second site with the following message in the footer of the cached page….

    Sorry – transcribing because copy paste doesn’t seem to be working in this box right now.

    Dynamic Page Served (once) in 0.707 seconds

    Page not cached by WP Super Cache. Could not get mutex lock. (same version as before 0.8.4)


  32. Donnca,

    Love the plugin and have been using it now for 6 months. Here is the odd thing that I have noticed. Without a doubt, from the day that I have started to use the plugin, analytics providers are showing a large variance in the #uniques that come to my site when compared to wordpress stats, as well as server logs, urchin etc… Is there any reason why this caching might do something with cookies or anything else that could be throwing this off? I show anywhere from a 10- 30% difference (lower) with what GA and quantcast are measuring vs. wordpress stats and other measurement tools. Quantcast seems to be the most off (I do have their JS installed), and compete has shown the site decreasing in traffic for 6 months despite a general uptick in visitors per GA and wordpress stats. Any ideas? I cant think of what might be the problem but it corresponds to the exact date that I installed the plugin.


    1. I don’t know why that’s happening Mark. If the JS for each service is hard coded in your template they should all show (mostly) the same thing. I say mostly because there are always slight differences.

      If there’s a plugin generating the JS make sure it’s executing correctly.


      1. Thanks Donncha,

        PS – sorry for the name misspell previously

        They are hard-coded into the site. It sure seems odd to me so I thought I would mention it. Not sure there is anything we can do about it.. It wouldn’t matter which settings I had within the plugin or which bots I exclude would it?


  33. I’m using WP Google Analytics plugin with WP Super Cache. You mentioned to Mark above that if a “plugin is generating the JS, make sure it’s executing correctly.”

    Well, ever since installing Super Cache several weeks ago, Google Analytics has not been tracking any of the data so the JS for the GA plugin must not be executing properly.

    Without having to do a manual install on each page of the GA code, can you suggest how I could make both of these plugins work together?

Leave a Reply