Thaya Kareeson has written an excellent article for plugin developers. It goes through how to make plugins work with WP Super Cache by using dynamic AJAX calls.
WP Super Cache can make static html copies of pages served by WordPress which is great for performance. Unfortunately that means some plugins don’t work because they rely on executing PHP on each request. The plugins need to be rewritten to use AJAX calls by the visitor’s browser. There’s a FAQ in the readme.txt all about it!
I previously wrote about adding AJAX to WordPress plugins but Thaya has worked through a simple example that will work perfectly with WP Super Cache. It’s a good foundation for plugin developers start from.
He also has versions of WP Postviews and Popularity Contest that have been rewritten to support static caching. I haven’t tried either plugin so leave a comment on his blog if you need help!
If you depend on a large portion of your content being dynamic this isn’t the solution for you as it will affect what search engines see. Those bots don’t speak Javascript, but for interactive purposes (ratings, stats etc) it’s the job.
- AJAX in Plugins is a must-read starting point for developers.
- wp_enqueue_script() is the command WordPress uses to load Javascript files. That page links to a couple of good pages too including this best practices post. As of this writing, Thaya’s example don’t use wp_enqueue_script() but it’s simple to use.
The vast majority of plugins work just fine with WP Super Cache, but some of the ones that don’t are quite popular. If your favourite plugin doesn’t work, why don’t you help the author out and fix it? You have all the source code after all and you’ll be helping everyone else who uses the plugin!


23 Comments
Nick (1 comments.) on March 10, 2009 at 2:22 pm.
I actually just had to do this exact thing for a contract gig. The client was using WP Super Cache and could not figure out why WP-Postviews wasn’t updating on refresh. I fixed it with AJAX, just like the author above.
GaMerZ (1 comments.) on March 10, 2009 at 3:51 pm.
I have updated the fix into the core code sometime ago. I tested it, it did count the hits.
Donncha (1707 comments.) on March 10, 2009 at 4:17 pm.
Gamerz – that’s great to hear. I should update the readme!
Pingback: Patoche On Web » Blog Archive » HOWTO: Make WordPress plugins work with WP Super Cache
Thaya Kareeson (1 comments.) on March 10, 2009 at 6:31 pm.
Thanks for writing about my post Donncha.
I wrote it because I still cannot use WP Super Cache on my site because of Who Sees Ads and a few other plugins. I would make them compatible myself, but there is definitely no time to do it all myself.
I was hoping that I can help urge all plugin developers make their plugins WP Super Cache compatible and I can eventually reap the rewards.
Eric Rachlin (1 comments.) on March 10, 2009 at 9:26 pm.
Couldn’t a similar method be used to eliminate the need to have separately cached pages for each logged in user?
Donncha (1707 comments.) on March 10, 2009 at 11:38 pm.
It certainly could but in most cases the number of anon users vastly out numbers the number of logged in ones so there wouldn’t be much of a performance gain.
In recent versions of the caching plugin the number of cache files has been reduced dramatically too.
Scott Tribe (1 comments.) on March 10, 2009 at 10:56 pm.
There is also a plugin out there called Widget Cache that can be used by folks.
Milan Petrovic (1 comments.) on March 10, 2009 at 11:04 pm.
Since WP Super Cache is very popular plugin and very useful, I am working on improving my GD Star Rating plugin to support it. Rating already works (partially at least, votes are saved), but is not always displayed right. This post is good starting point to add cache support.
George Serradinho (4 comments.) on March 11, 2009 at 5:57 am.
Thanks for this info, I’m sure all the developers will include it in their plugins as many users use WP Super Cache
Pingback: Make WordPress plugins work with WP Super Cache | David Bisset: Web Designer, Coder, Wordpress Guru
Pingback: Tweeking WP-Super Cache to Play Nice with Your Other Plugins | 24/7 WEB PROS
Sarsura (6 comments.) on March 12, 2009 at 2:10 pm.
very nice how-to, thank you for the information about it.
androidandme (1 comments.) on March 13, 2009 at 2:36 am.
I love wp-super-cache. You helped me survive a big traffic spike yesterday. I looked for a donate link on your site but could not find one.
Lisa Angelettie (1 comments.) on March 13, 2009 at 3:21 am.
Just wondering what the other plugins are that this plugin doesn’t work with. I have installed super cache but on a recommendation from someone. I haven’t actually done my due diligence on how to make sure it works properly. I just was concerned about my site loading faster.
Thanks,
Lisa
Donncha (1707 comments.) on March 13, 2009 at 11:47 am.
Lisa – plugins that update the page based on user interaction may not work. I’d say most plugins will work just fine.
Android – check the supercache page, there’s a big donate link there and on the admin page too!
Pingback: Total Fucked? » Blog Archive » WordPress News: Plugins Reach Milestone, New WordPress Community Project, Help to Search for WordPress Help
WPForInternetMarketers (1 comments.) on March 18, 2009 at 3:36 am.
Wow, I wish I had googled this last week it would have saved a headache! Thanks for the links to the articles and the information.
All the best
Leanne
netlog (2 comments.) on March 23, 2009 at 7:57 pm.
Sorry im not very newbie in php but what is ajax? from where can i learn something about this programmin language? and can you advise me some books name related to ajax? thanx
Keith Price (5 comments.) on March 31, 2009 at 6:43 am.
Excellent! That’s exactly what we need. As someone new to blogging, I’m afraid to use a caching plugin for that very reason. I don’t know how to tell what it will break.
Dizi izle (1 comments.) on October 2, 2009 at 8:33 pm.
Couldn’t a similar method be used to eliminate the need to have separately cached pages for each logged in user?
Jeff (1 comments.) on November 13, 2009 at 10:31 pm.
I use the “More Fields” plugin, which lets me add a “File List” Custom Field to my Add/Edit Post pages. The “File List” control works by issuing an AJAX request to “/wp-content/plugins/more-fields/more-fields-write-js.php?post_id=xxx&…”, but that request fails when WP Super Cache is enabled — even when I explicitly add “more-fields-write-js\.php” to list of strings not to be cached.
Here’s why: at the time the AJAX request is made, I have to be logged in, and the effect of being logged in causes WP Super Cache to append the string ‘‘ to the AJAX result, which effectively mangles the JSON string being returned.
My solution was to rearrange a couple of tests being performed in wp-cache-phase2.php, so that it *FIRST* checks “if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri))” *BEFORE* it checks “if ( $wp_cache_not_logged_in && is_user_logged_in() && !is_feed() && !is_admin() )”.
This simple change insures that anything I explicitly block from being cached won’t be modified either. This allows “More Fields” to work properly, and it allows me to easily fix any other incompatible plugins that I might run into.
If this change is safe enough to incorporate into WP Super Cache, that would be ideal — or if you have a better solution, even better. In any case, thanks for a great plugin!
Yoav Aner on June 26, 2011 at 3:34 pm.
I’ve written a small plugin that automates most of this process for you, so you can take almost any plugin function and ‘ajaxize’ it. No need to be a programmer or mess around with javascript. For more info see http://blog.gingerlime.com/ajaxizing