Speed Up WordPress WITH or WITHOUT a WordPress Cache
Although using a plugin that caches WordPress is the best overall solution, I can't use any of them with the way I run this blog. I did the research, tried the hacks, and ended up falling flat on my nose. I'll explain what I finally ended up doing after I list the options.
WordPress Caching Plugins
There are a few plugins that work well. There may be more, but these are ones I know about. I'll try to keep it all in order and add notes and links.
This is probably the one that started it all. It was abandoned by the author on [it looks like] October, 24, 2007 when he abandoned his blog. The only way to enable compression with it is to enable zlib.output_compression in the php.ini (if you have access to it) and disable the compression inside of WordPress (not included in the current version anyway). The latest version of WP-Cache still works with WordPress.
This is exactly like WP-Cache except that it works on servers where symbolic links can't be used or accessed.
Based on WP-Cache and HTML Cache Creator, it's been around for about 10 months (as of today's date). I haven't tested it and have no desire to do so. It's compatible with WordPress up to 2.2 and I'm well past that point.
This is WP-Cache on steroids. It supports compression immediately on install and serves .htaccess-driven static files as well as the WP-Cache-type files. Which files get served depends on cookies. If you have the zlib compression in your php.ini enabled, you have to disable it in order to use the built-in compression.
This plugin does not rely on the existing code of WP-Cache in any way. I tested it. It servers static, uncompressed files, though compression can be used through the php.ini just like WP-Cache.
Dynamic Code
All of the listed caching plugins, except for Hyper Cache, use the mclude and mfunc conventions. WP Super Cache uses it for the regular cache part, but not the super cache part, which is understandable because no php code is executed in true static files.
A lot of people don't know how to use the conventions, but I spent some time testing them. If you do something like this:
<--mclude testfile1.php-->
<?php include 'testfile1.php' ?>
<!--/mclude-->
The cache plugin will change the middle line to <?php include_once('testfile1.php'); ?> regardless of what you put there. Your original line will execute prior to being cached and the substituted line will be executed when the file is loaded from the cache.
If you don't inlcude testfile1.php in the first line, the code in the middle will remain untouched. The mfunc works in the same way, except with functions.
My Own Speed Up Solution
With all the plugins available, I decided not to use any of them and use something that previous versions of WordPress used: On the fly compression. The reason is strictly because of the Google AdSense ads.
I use code to prevent Google AdSense ads from showing to anyone but search visitors. If I use WP Super Cache, regardless of which caching method I use, the cached page is based on the first person to load the page. If the first person doesn't see ads, neither will the search visitors that follow him or her until that page has expired in the cache. On the other hand, if the first search visitor sees ads, the next non-search visitor will see the ads until that page has expired from the cache.
In this case, the cache defeats the purpose of conditionally displaying the AdSense. Setting the cache to expire quickly doesn't help. The dynamic code I mentioned above doesn't work with my conditional code unless I rewrite it for that purpose and it still only works for the non-super cache part of the plugin. In my opinion, having dynamic code within a cached page kind of defeats the purpose of the cache anyway.
I enabled on the fly compression by inserting ob_start("ob_gzhandler"); just above /* Short and sweet */ line in the main index.php for the blog. I also enabled on the fly compress for my CSS file by changing the link in the header.php file to style.php after inserting the following code at the top of my style.css file and saving it as style.php. [Warning: I was suspended on shared hosting for using this due to the CPU spikes.]
<?php
ob_start ("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 1440;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>
The Future
The problem with displaying Google AdSense ads conditionally using JavaScript itself is that it's against their Terms of Service. It would solve my caching problems. I understand I can send them email and get permission to use the modified code, but I haven't written it yet. Once I write it, I'll be sure to make it available for everyone to use (with Google's permission, of course).
If I decide to stop displaying AdSense ads to search visitors as well as everyone else, the issue will resolve itself. That day is far in the future, however, as this is my primary online income at the moment.
More Notes
I only wrote about caching and compression. There are other ways to speed up a WordPress blog that I won't get into at this time. The short version is that you have to reduce queries, function calls and HTTP connections.
I have only one question. Are there any brilliant JavaScript programmers out there that can figure out how to write conditional JavaScript WITHOUT altering the AdSense code (including the script tags)?
(Update: I worked with the author of Hyper Cache to create two separate cache files; 1 for search visitors and 1 for non-search visitors. I am now using both the "on the fly" compression and Hyper Cache.)
Similar Posts:



I myself don't bother about such issues because I don't think I get the traffic to justify having to "speed up" my website and secondly the server I'm hosted on is a very good one and doesn't host too many other sites.
Minor gripe — there's no such word. Regardless it is.
At least it shows I'm reading your posts though
My latest blog post: Boxi and Panjo – Farewell to Thee
You're right. I meant to fix that and I just did. Damn spellchecker POS.
Yep, you had to read it in order to catch that!
Oh, and it's not really about the server issues. I just found out (like yesterday) that the speed of your pages affects (to what degree I don't know) their position in the SERPS. The faster, the better.
Didn't know about the effects on SERPs but it makes sense- if the googlebot takes too long to load, then I can see getting dinged.
My latest blog post: Paula Dean's Imitation Crab Meat Stuffed Mushrooms En Croute
Ah OK, but any PHP application that queries a MySQL database is bound to slow down the overall loading.
Maybe the lightweight embedded SQLite which is standard in PHP 5 will be a future solution for small websites with less SQL requirements. MySQL runs as a separate server-side application on the web host and has a large overhead.
My latest blog post: Boxi and Panjo – Farewell to Thee
Very interesting read, thanks for putting in the work and sharing this with us.
No problem, Gavin. I spent 3-4 days working on backend programming. It kind of leaves no time for the stuff I really want to write about.
Yah but if your anything like me you love the programming right, almost as enjoyable as blogging.
Not really the programming, but solving a programming problem. It can be time consuming and yes, it can be just as enjoyable as blogging.
hi RT, I've noticed a couple of times over the last day or two that when I checked Untwisted Vortex I would get a blank white page. A few minutes later it would load as normal. I'm wondering it this was during your testing and was what you described as "falling flat on my nose". ~ Steve
Yes, more than likely. I tried to limit the time testing, but shiitake happens.
Yeah! I also know that solving a programming problem is also enjoyable as blogging.
[...] each other's comments and interrupt the flow of good discussions. I found this article on speeding up Wordpress without a cache, but the only way I can know if it works is to disable WP-Super-Cache, implement that solution, [...]
We are getting ready to start developing in Drupal but we have been researching the differences between Drupal an WordPress and the effects of CSS with both… Can anyone provide any feedback between the pros and cons of each? Thanks!
WordPress seems to have a lot more themes available for it than Drupal, but both are relatively easy to style, IMO.
There are a few Drupal themes that make it really easy to create great looking sites just using CSS. Have a look at the Zen theme for Drupal. You can adapt the look and feel just using CSS as the template codes include almost everything you could possibly need.
My latest blog post: Save Space When Backing-Up Drupal Database
I just want to share WordPress benchmarks with and without WP-Cache. Clean WordPress on 2.6Ghz dual core P4 with 1Gb of RAM with Linux, can give only 3.44 requests per second. After WP-Cache installation score was 235 requests per second. If you have ability to install APC, you can double throughput and server could serve 467 requests per second.
can i actually use this code on my blog? are there any downside i should know before applying it??
My latest blog post: How to add a Send Link button in Google Chrome
If you use the ob_gzhandler on shared hosting, you'll probably get suspended like I did. I'm moving to dedicated hosting.
Thanks for your tips. I've always been thinking how to make all my BLOGs response faster.
My latest blog post: Online Reading Comprehension Test is Launched
this article is marvles and i cant even rate it!!!!!! a bigggggggggg thanks to the author…
I can use this info to make my wordpress load faster.
My latest blog post: Penis Advantage Review
Nice article. I was looking for the same solution.
My latest blog post: Fat Binders for Weight Loss
Thanks a lot for this article. Now my wordpress blog is going so fast… but I choosed the non-cache option.
My latest blog post: Endurance de 24 heures non stop !
Thanks for the article – one newbie question though: will wp-supercache work ok with google adsense if you're NOT using any conditional displays for the ad (i.e. if your page will always display the ad) – a bit nervous about breaking adsense terms and conditions!
Thanks again!
My latest blog post: Invitation to Write Articles for Wonkie
Yes, it will. AdSense is displayed using JavaScript, which isn't affected by caches.
This is great! Sometimes I'm using Wi-fi in the nearby cafe and can be really slow online connection. I hope this will help! Thank you!