Plugin Output Cache

Caveat

Unfortunately, due to ill-health, this plugin has not been developed or supported properly for some years. It works with the latest versions of WordPress (including on this website) but could possibly conflict with any WordPress features added after 2008 — e.g. custom post types — if you use them.

Purpose

This plugin provides a way for other plugins to cache their output and speed page display. Most of my plugins use the cache automatically if it is installed. The cache is cleared automatically whenever the blog content changes so that the retrieved output is always fresh.

This is version 4.0.8 download latest version. It is faster, easier to use, and also cleans up after itself when deactivated.

Installation Instructions

  1. If you are upgrading from an earlier version first deactivate the old plugin via the Plugins menu and then delete the plugin directory from your server.
  2. Upload the whole plugin folder to your /wp-content/plugins/ folder.
  3. Go to the Plugins page and activate the plugin.
  4. Go to the Manage page and switch on caching.

Usage and Options

The plugin does nothing on its own! It exists only as a helper for other plugins. However, if my other plugins are installed they will automatically have their output cached.

You can tell if the cache is working properly by looking at the source of a browser page which uses one of my plugins, e.g., Recent Posts. Underneath the output from the plugin there will be an HTML comment telling you how long the plugin took to produce its output and whether it came from cache.

If you upgrade any plugin that uses the output cache plugin remember to clear the cache or you will not see the results of the change. The Plugin Output Cache installs a page under the admin Manage menu with a button to clear the cache and a button to switch caching on and off.

The Manage page also give you the option to collect data on how efficient the cache is on your blog. N.B. Collecting the statistical data makes the cache about 20 times slower so it should only be done to satisfy your curiosity and not as a a matter of routine.

I have defined efficiency as the percentage of cache requests actually served from the cache. After the cache has been cleared the first requests are for items that have not yet been cached and efficiency will be poor but as repeat requests are made the efficiency rises rapidly. In my experiments 85% – 95% are common. Of course every time someone makes a comment the cache is cleared and the efficiency drops again.

How to Use Plugin Output Cache for your Plugins

The Plugin Output Cache can be used by other plugins which produce output by making minor changes to them.

The Plugin Output Cache defines a constant POC_CACHE so you can check if the cache is available. Version 4.0+ also defines POC_CACHE_4 which lets you take advantage of version 4’s new features. Plugins adapted to work with earlier versions will continue to function normally.

The Recent Posts plugin shows in detail how to do it incorporate caching. The outline is as follows. Instead of:


function your_plugin() {
	$result = get_plugin_output();
	echo $result;
}

Use:


function your_plugin() {
	if (defined('POC_CACHE_4')) {;
		// $key is some unique string to identify the output
		$result = poc_cache_fetch($cache_key);	
		if ($result !== false) echo $result;
	}
	$result = get_plugin_output();
	if (defined('POC_CACHE_4')) poc_cache_store($cache_key, $result); 
	echo $result;
}

Note: This presumes your plugin can be written to return its output as a string or signal failure by returning ‘false’.

Your code should also clear the cache whenever your plugin’s options are updated.


	if (defined('POC_CACHE_4')) poc_cache_flush();

112 Comments

  • 1. Ajay  |  February 12th, 2007 at 5:36 pm

    Great development indeed. Btw, in the implementation above, shouldn’t you be having an else loop?

  • 2. Rob  |  February 12th, 2007 at 6:29 pm

    Ajay: Can you be more specific about the need for an else clause? I may be being dense but I can’t see the need…

  • 3. Everton  |  February 13th, 2007 at 12:11 pm

    I think what Ajay means is what the author’s plugin should do if your plugin isn’t installed, but I think you’ve already got that covered.

    I’m gong to try it with my Latest Comments With Avatars plugin which can be slow as it retrieves the avatars on every page load.

    I also have APC and WP-Cache installed on my site, so I’ll give you some good feedback

  • 4. Rob  |  February 13th, 2007 at 4:58 pm

    Everton: I see what you mean. Thanks for trying it out. I need the feedback.

  • 5. Tin  |  February 13th, 2007 at 8:55 pm

    will this conflict with wp-cache? i’ve been using that successfully for the past year…

  • 6. Rob  |  February 13th, 2007 at 10:11 pm

    Tin: If you use WP-Cache you should have less need for this plugin. When WP-Cache has to render new pages rather than fetch them from the cache, this plugin should, in principle, speed that up since many pages uses the same block of output from Recent Posts say. I don’t really think that will have a big impact though and if you run WP-Cache you probably don’t need the Plugin Output Cache. But I’d like to be sure about whether having both installed messes both up or if they play well together.

  • 7. Lazy  |  February 14th, 2007 at 7:19 am

    i`ve installed the cache plugin yesterday and run it together with wp-cache 2.1 -> works fine, nothing messed up or something like that. :)

  • 8. Rob  |  February 14th, 2007 at 8:27 am

    Lazy: That’s good news. Thank you.

  • 9. Lazy  |  February 15th, 2007 at 5:43 pm

    no prob.. just a great plugin :)

  • 10. pufaxx  |  February 19th, 2007 at 8:12 pm

    Hi Rob,

    indeed, that’s a good idea to cache plugin’s outputs, and I’m just trying around with your PlugIn on a WordPress 2.1 installation. But at first it did noch work for me – because I have an other database-prefix in than “wp_” in my “wp-config.php”-definitions.

    For WordPress 2.1 I had to change the code from line 42 – 52:

    // delete all the data in the cache
    function clear_all() {
    	global $wpdb;
    	// $wpdb->query("DELETE FROM `wp_options` WHERE `option_name` LIKE '" . CACHE_PREFIX . "%'");
    	$wpdb->query("DELETE FROM `".$wpdb->prefix."options` WHERE `option_name` LIKE '" . CACHE_PREFIX . "%'");
    }
    	
    // count how many entries are cached
    function count_entries() {
    	global $wpdb; 
    	// return $wpdb->get_var("SELECT COUNT(*) FROM `wp_options` WHERE `option_name` LIKE '" . CACHE_PREFIX . "%'");
    	return $wpdb->get_var("SELECT COUNT(*) FROM `".$wpdb->prefix."options` WHERE `option_name` LIKE '" . CACHE_PREFIX . "%'");
    }

    As I don’t have any WordPress$table_prefix instead of $wpdb->prefix …?

    Anyway – Good work – And I think, your PlugIn will help lots of people getting their blog running much faster.

    Thank you,

    Gunnar

  • 11. pufaxx  |  February 19th, 2007 at 8:22 pm

    Ooops!

    Some of my words words were “stolen” by “making” HTML-tags of < and the following letters. I wanted to write:

    As I don’t have any WordPress<2.1 running at the moment, I could not try what is to do for earlier versions. If these changes don’t work, it might help to write $table_prefix instead of $wpdb->prefix …?

    Sorry about that.

    :-)

  • 12. Rob  |  February 19th, 2007 at 10:12 pm

    pufaxx: You are, of course, perfectly right. I am embarrassed to have made a slip like that. Thank you.

    Fixed in v2.1.1

  • 13. pufaxx  |  February 22nd, 2007 at 5:44 am

    Hi Rob,

    as I have also some problems with WP-Cache, I am now using your PlugIn not only for caching the output of other PlugIns:

    I have copied (and renamed) some wordpress-functions like wp_list_pages and others into an extra PlugIn, so I can use them with POC-cache.

    It works great and the performance has improved extremely.

    Okay, there must be an individual $key for everything that’s cached, and some of the wordpress-functions have to be cached “per post” – so that I produced about 500 of POC-entries in my database, now – but … so what?

    :-)

    I’m trying around – and there’s still a lot of space in my database …

  • 14. Rob  |  February 22nd, 2007 at 8:10 am

    pufaxx: I’m glad to hear it’s helping! My similar posts plugins also produce output per post so I’ve been watching the number of cache entries get well into triple figures but so far at least it doesn’t seem to have any bad effects on the database and the cache-retrieval times aren’t affected. I have toyed with setting up a custom table for the cache rather than using wp-options but the present method works so well I’m am loathe to re-invent a very smoothly running wheel.

  • 15. lee  |  April 20th, 2007 at 3:22 am

    what is the difference between this plugin and wp-cache
    http://mnm.uib.es/gallir/wp-cache-2/

    can i use “Output Cache” with HideIt ?
    http://00schmidt.com/wp/?p=306

    i can use Hideit with wp-cache.but if i can use this plugin with Hideit i want switch to this plugin.

    thanks.

  • 16. Rob  |  April 20th, 2007 at 8:00 am

    lee: WP-Cache caches all the output generated by WordPress so that whole pages are stored. Furthermore, when it is working it automatically does its work.

    The Plugin Output Cache is different. It only does anything if a plugin author has adapted their plugin to use it, to save regenerating its output needlessly. WordPress still generates its pages dynamically but pulls in the cached plugin output where it belongs.

    This plugin shouldn’t interfere with other plugins.

    The Plugin Output Cache isn’t a replacement for WP-Cache as they do different jobs.

    Does this answer your question?

  • 17. lee  |  April 30th, 2007 at 11:48 am

    >Rob

    Thanks. I have one more question

    >This plugin shouldn’t interfere with other plugins.

    you mean can i use “Output Cache” with HideIt ?
    http://00schmidt.com/wp/?p=306

  • 18. Rob  |  April 30th, 2007 at 12:29 pm

    lee: The Plugin Output Cache only caches the output from plugins that have been specially written to use it. In principle it should have any interactions with other plugins… I haven’t tried it specifically with the plugin you mention.

  • 19. Richard  |  June 1st, 2007 at 10:40 pm

    (I’m using POC 2.1.2 beta, as well as Similar Posts 2.1.1 beta)

    Had a strange bug that plagued me for a while before I got around it. I created a new post and saved it. Then I changed some options in the Similar Posts, surfed around my blog, and later changing my mind by setting the options back.

    The problem was that the Similar Posts were cached. I cleared the POC cache, and refreshed the page on the new post. But the old cached data appeared. I turned off the cache and cleared it. New Similar Posts HTML showed up as expected. Turned the cache back on and received the *old* cached HTML again. I hit the clear cache button several times, and it returned 0 items cached each time.

    The eventual solution was to edit *another* post, after which the cache seemed to actually clear properly and the correct HTML was shown. Now all is fine.

    Sorry for the longwinded post, but I’m trying to be as clear as possible. This generally seems to work well enough that I think you should take over the ailing WP-Cache2. :)

  • 20. Rob  |  June 2nd, 2007 at 8:04 am

    Richard: I’ll look into whatever is going on there. Thanks.

  • 21. Mark  |  June 21st, 2007 at 9:52 pm

    WordPress already has a caching system built in that is very similar to this – take a look at wp-includes/cache.php. It’s used internally by WordPress and is available to plugins too.

  • 22. Rob  |  June 22nd, 2007 at 8:37 am

    Mark: Unfortunately I have never been able to get the built-in cache to operate on shared hosting running in safe mode. As I understand it the built-in cache is also off by default since it can result in an overall speed decrease. The plugin output cache answers a more specific need.

  • 23. ovidiu  |  October 24th, 2007 at 7:23 am

    hello,
    I have a problem with plugin output cache and recent posts plugin (both your plugins). recent posts works great, uses the changes I set in the options page, but if I activate plugin output cache, it shows me (for any posts) only 3 links to recent posts, altjhough I have highly customized the formatting and output in the options page of recent posts plugin.
    Emptying and even disabling cache does not help, I have to deactivate the plugin output cache to get the customized results.

  • 24. Rob  |  October 24th, 2007 at 9:23 am

    ovidiu: I am mystified. I can’t reproduce the problem here and the plugin cache and recent posts seem to be working together. Can you give me any clues about your setup that might be relevant? We need to get to the bottom of this.

  • 25. ovidiu  |  October 24th, 2007 at 9:33 am

    I don’t think I can give you any clues… lots of plugins working on this site.
    All I can offer is an admin account for an hour or so, so you can have a look for yourself. This is all I can try because I am currently working on this site, and I am almost done with it.

    ONE more thing I’d like to try is give this another go from home, as at work (currently sitting there) I have severall proxies and firewalls between me and the net so it might be a proxying issues although I doubt it.

    I’ll contact you again here later on today after work.

  • 26. Rob  |  October 24th, 2007 at 9:36 am

    ovidiu: OK.

  • 27. Rob  |  October 27th, 2007 at 3:00 pm

    Plugin Output Cache version 3.0.0 has been rewritten for greater speed and lower memory consumption. Please give it a try and let me know of any issues.

  • 28. ovidiu  |  October 28th, 2007 at 9:00 am

    can you help out using your plugins with wpmu?

    here is a forum post regarding this plugin: http://mu.wordpress.org/forums/topic.php?id=6638&page&replies=1

    thx a lot for your plugins.

  • 29. Rob  |  October 28th, 2007 at 9:18 am

    ovidiu: I’ll do what I can but I Know nothing about WPMU.

  • 30. ovidiu  |  October 31st, 2007 at 1:16 pm

    hello, having some problems on wp 2.2.3
    using recent posts, recent comments and plugin output cache, all latest versions as of now.

    POC shows 2 items in cache – always.

    check it out:

    http://www.ronduldesibiu.ro/ read any article, below every post, it should show 3 recent posts from the same category.

    I call it like this inside my template:
    <?php if(function_exists(‘recent_posts’)) {echo(‘Alte articole din aceasta rubrica:’);recent_posts();} ?>

    3 categories are excluded and all others are included.
    BUT the recent posts shown below are not limited to the same category although I checked this.

    can you have a look please?

  • 31. ovidiu  |  November 2nd, 2007 at 8:24 am

    ok, I have to deactivate the plugin output cache now, can’t let it work online anymore, as it mixed everything I described above up for me.

  • 32. Rob  |  November 2nd, 2007 at 9:36 am

    ovidiu: I’m sorry you are having these problems. I did look at the site but it gave me no clues. Am I right in understanding that recent-posts works properly if you deactivate the plugin cache?

  • 33. ovidiu  |  November 4th, 2007 at 9:00 pm

    yes, I deactivated the poc and now all is fine…

    I will live without it until I really need it and then try again maybe with never versions,,,..

  • 34. Diwaker  |  January 12th, 2008 at 3:11 am

    I’m using several of your plugins (Recent Comments, Recent Posts etc), all latest versions, on WP 2.3.2. The problem is that the plugin cache doesn’t seem to be working properly. When the cache is disabled, things look fine and I see “POC Cache Miss” comments in the output.

    However, when I enable the cache, the Recent Post/Comments plugin ALWAYS show “None found” in the output, and the comment still says “POC Cache Miss” despite refreshes.

    I have WP Super Cache installed, but I tested with Super Cache disabled and I still see this problem. Any thoughts? Similar to the problems ovidiu seems to be having.

  • 35. Rob  |  January 12th, 2008 at 10:16 am

    Diwaker: Just to check the obvious… you have flushed all the caches completely and the problem still persists?

  • 36. Diwaker  |  January 13th, 2008 at 12:31 am

    Rob: yep, I had flushed the caches. I think I have identified the problem though. For some reason, the widget was only displaying posts that matched tags of the current post even though it was NOT set in the options. I set and reset that setting again and now it seems to be working fine. Thanks!

  • 37. Rob  |  January 13th, 2008 at 10:40 am

    Diwaker,

    That’s good news!

  • 38. Shanx  |  February 8th, 2008 at 4:36 am

    Would this in any way conflict with WP-SuperCache?

  • 39. Rob  |  February 8th, 2008 at 10:34 am

    Shanx: It didn’t conflict with WP-Cache… I haven’t heard of any conflicts with its successor either and I don’t expect any. I’d be interested in finding out for sure though.

  • 40. Fendi  |  February 13th, 2008 at 7:03 pm

    Hi Rob,

    Call me dumb. LOL!

    I have your other plugins Similar Posts and Similar Posts Feed, so i just turn Cache on and that’s it right?

    Great to know it didn’t conflict with SuperCache though.

  • 41. Rob  |  February 13th, 2008 at 10:12 pm

    Fendi: Yes, just activate the plugin and then go to the Manage page and switch it on. You can check it is working by visiting a few pages with Similar Posts showing and then checking the POC Cache page to see that some stuff is stored in the cache.

  • 42. Fendi  |  February 18th, 2008 at 6:50 pm

    Thanks Rob!

    I’ve tried your instructions and it worked.

    Do we have to clear the cache at all or does it auto-clear after a period of time?

  • 43. Rob  |  February 19th, 2008 at 1:09 am

    Fendi: It clears whenever a new post or comment is made, or if you change a plugin’s options.

  • 44. Fendi  |  February 27th, 2008 at 1:36 am

    Thanks Rob.

    I’m full steam ahead!

  • 45. Rob  |  February 27th, 2008 at 9:36 am

    Fendi: Good to hear.

  • 46. Richard D. LeCour  |  March 8th, 2008 at 8:52 am

    Took me about an hour to realize that the plugin wasn’t working because I had changed the default folder name from POC_Cache to poc-cache, and the add_actions in the poc-cache-admin.php weren’t being fired off.

    You might want to try using something like the following:

    'activate_'.$this->plugin_basename(__FILE__)

    (I’m hoping the above looks OK first time because you don’t have a Preview Comment button!)

  • 47. Rob  |  March 8th, 2008 at 5:57 pm

    Richard: Thanks for the report. I’ll fix it in the next versions of my stuff.

    Just out of interest … why did you rename the folder?

  • 48. Richard D. LeCour  |  March 8th, 2008 at 8:25 pm

    @Rob: Because 99% of all plugins use lowercase for folder and file names, and they generally use a hyphen instead of an underscore, so it just looks better to have them all look alike. I just went ahead and changed it because it didn’t even occur to me that the folder would be hardcoded.

    I used to use your plugin a long time ago (comment #27 above is from me, too!) and for whatever reason I had deleted it. Just picked it up again which is why I reinstalled from scratch and ran into this issue. The latest versions (currently in development and QA) of a few of my existing and new plugins will be POC-ready. My pages are now loading faster by about 0.2 seconds each, and with 10% fewer DB queries. Thanks!

  • 49. Perry  |  March 10th, 2008 at 8:38 pm

    Hi everyone.. I need a little help, and was wondering if any of you would like to take a quick job on.. I’ll be willing to pay a nominal fee if someone can add the POC code to three of my plugins:

    1. Event Calendar – It’s kind of complicated, and performs multiple queries and LEFT JOINS.
    2. Recent Comments (not Rob’s.. a different one, I had issues with styling, etc.)
    3. Show top Commentators

    Additionally, if you’re talented, if my Event Calendar plugin could be reconfigured to query the database only once per day (say at 5:30am daily), otherwise stored and cached output would be displayed. I use this plugin only to simply display a short list of upcoming events in my sidebar.. with URL to post..

    I’ve zipped and uploaded the three plugins in question.

    Any takers? I desperately could use the help. My site has grown so fast and I cannot seem to “crack the code”… this on top of all the MySQL and Apache tweaking I’ve needed to do.

    Your help would be greatly appreciated.

    You can email me at periginald@gmail.com
    Thanks.

  • 50. Richard D. LeCour  |  April 26th, 2008 at 9:58 pm

    Despite my long history with this plugin, I have been completely unsuccessful getting either v3.0.1 or v4.0.0 to work with WP 2.5.1. I do not use the standard “wp-” table prefix, but the v3.x plugin worked fine with WP 2.3.3 and my nonstandard prefix. so I doubt that’s the issue.

    Here’s the code from my sidebar that worked with v2.3.3:

    $result = false;
    $key = “whatever”;
    if (defined(‘POC_CACHE’)) {
    $cache = new POC_Cache();
    $result = $cache->fetch($key);
    }
    if (false === $result) {
    $result = get_the_results_of_the_plugin();
    if (defined(‘POC_CACHE’)) {
    $cache->store($key, $result);
    }
    }
    echo $result;

    I’m completely stuck.

  • 51. Rob  |  April 27th, 2008 at 11:12 am

    Richard D. LeCour: You are quite right that for some reason the ‘legacy’ way of using the plugin cache has stopped working. Thanks for spotting the problem. I will be looking into it. Meanwhile, try the updated method which uses a pre-built instance of the cache. It is still working!

    
    	$result = false;
    	if (defined('POC_CACHE_4')) {
    		$key = 'whatever';
    		$result = poc_cache_fetch($key);
    	}
    	if ($result === false) {
    		$result = '<br><b>hello</b>';
    		if (defined('POC_CACHE_4')) {
    			poc_cache_store($key, $result); 
    		}	
    	}	
    	echo $result;
    

  • 52. Richard D. LeCour  |  April 27th, 2008 at 6:40 pm

    I tried exactly what you have above several times yesterday, and still couldn’t get the plugin to work.

  • 53. Rob  |  April 27th, 2008 at 9:07 pm

    Richard: That’s bad news because I have it working here. What does the plugin cache management page say?

  • 54. Richard D. LeCour  |  April 28th, 2008 at 5:15 pm

    The management pages says “The Plugin Output Cache is ON” but “There are 0 items in the cache” which never changes. If I turn statistics on, the “Number of misses: 0 Number of hits: 0″ counters never change. Refreshing any of my pages regenerates the cloud tag in the sidebar every time, one of the features I had previously successfully cached with POC 3.x and WP 2.3.3.

    I suspect that the cached data is not being stored. I have confirmed that the database is successfully created upon activation, and dropped upon deactivation.

  • 55. Rob  |  April 28th, 2008 at 10:23 pm

    Richard: Thanks for the extra info. I’ll try and track down the problem as soon as I can.

  • 56. Hype  |  May 6th, 2008 at 3:05 am

    Man, I love your plugins. Very customizable as we cant see out there! Thanks a lot.

    The output cache for me is now showing the administrative page on settings.

    Whem I try to click on the link that show on the activated plugin (http://hypescience.com/wp-admin/edit.php?page=poc-cache/poc-cache-admin.php) it shows the message “Cannot load poc-cache/poc-cache-admin.php.”

    I am using wp 2.5.1, Windows 2003 web, iis6 and the issue noes not looks like permission because I gave full control to everyone on the plugin folder.

    Thank you again,

    Hype

  • 57. Hype  |  May 6th, 2008 at 3:07 am

    sorry! now = NOT in the comment above.

    Oh, I was not using this plugin before. I uninstalled and reinstalled it many times, always deactivating the plugin before deletion.

  • 58. Rob  |  May 6th, 2008 at 9:51 am

    Hype: Have you looked under the ‘Manage’ menu? That’s where the cache can be turned on or off etc.

    I’m not sure about the link not working. Let’s address that after finding out about the Manage page.

  • 59. Richard D. LeCour  |  May 6th, 2008 at 3:37 pm

    it shows the message “Cannot load poc-cache/poc-cache-admin.php.”

    That’s because the folder hardcoded in the link (/poc-cache/) does not match the installation folder (/plugin-output-cache/ or /POC_Cache/ — depending on the version). Just ignore the error and visit the Manage page instead.

    (Haven’t had a chance to test your gz fix suggestion yet)

  • 60. Rob  |  May 6th, 2008 at 6:13 pm

    Guys: There is new version of the plugin output cache out which fixes the stray link and, I hope, fixes Richard’s bug too. (Richard, please let me know!)

  • 61. Tony  |  May 20th, 2008 at 6:08 pm

    My PHP error logs are filling up.

    
    [Tue May 20 12:02:45 2008] [error] [client 74.61.80.117] PHP Warning:  mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/shop/public_html/ca/wp-content/plugins/plugin-output-cache/poc-cache.php on line 105, referer: http://ca.shop-network.org/
    

  • 62. Rob  |  May 20th, 2008 at 11:11 pm

    Tony: Thanks for the report. I’ve made a code change which I think eliminates the warning message and sent it to you to test out.

  • 63. Perihelion  |  May 28th, 2008 at 9:34 pm

    I’ve just come upon some suspect behaviour:
    I have Recent Comments set in the sidebar, and another output under the post excerpt (thank you for so graciously adding this functionality, it is working perfectly). However, when enabling the output cache, only the sidebar output is displayed, the loop recent comments just disappear (cache stats indicate it is serving output to your various plugins).

    Is this intended behaviour? Am I doing something wrong?

  • 64. Rob  |  May 29th, 2008 at 12:13 am

    Perihelion: That does sound suspect! I’ll look into it after a night’s sleep…

  • 65. Rob  |  May 29th, 2008 at 10:47 am

    Perihelion: I’ve sent you by email a version that might correct your problem. If it does I’ll release it.

  • 66. Artefact  |  May 29th, 2008 at 8:27 pm

    Still doesn’t display the front page output (I tried logged in and out). If anything the performance seems to have decreased – was 100% efficient previously, now it seems about 85%.

  • 67. Rob  |  May 29th, 2008 at 9:31 pm

    Artefact/Perihelion: I’m glad to hear about the efficiency — the way it is defined it can never be 100% since the it takes a cache miss to load the item into the cache.

    Can you leave me a bug report from the Recent Comments settings screen? That will give me some extra debugging info. Can you also add the parameter string you use for the call under the posts? I’ll see if I can duplicate the cache problem and then have a chance to solve it.

  • 68. Saadat  |  June 14th, 2008 at 11:08 pm

    Hello Rob!

    I tested POC with your Similar Posts plugin and some other plugins on localhost, and it worked perfectly. However, when I activated POC on my remote server, I faced the exact problem mentioned by Richard in comment no. 54.

    I checked the database, and I also found out that the cached data is not being stored. I was wondering how Richard solved the issue, and hoping you could guide me through it. (I am using the version 4.0.6.)

    Thanks. :)

  • 69. Rob  |  June 15th, 2008 at 10:05 am

    Saadat: That’s an interesting puzzle. Why would it work locally but not on your remote server? Strange. Could you let me know some details of the two setups (OS, server, PHP, MySQL)?

  • 70. Saadat  |  June 15th, 2008 at 11:54 am

    Rob: These are the details of both setups.

    localhost: XAMPPlite version 1.6.5
    OS: Windows XP
    Server: Apache 2.2.6
    PHP 5.2.5
    MySQL 5.0.51.

    Remote server:
    OS: Linux
    Server: Apache 1.3.39
    PHP 4.4.7
    MySQL 4.1.22.

    Could it be that they need to upgrade at my remote server?

  • 71. DG  |  June 15th, 2008 at 11:56 am

    Hi Rob,

    I had writen a contact message / comment about 1+ month ago, but couldn’t hear anything so far. I’m in urgent need of your help for optimizing my db queries. Actuall I’m facing lots of problems for the past 1+ months, after moving to DreamHost VPS.

    I’ve tried to use your POC-Cache plugin with some WordPress built-in function, but couldn’t let it run.

    May I request you to give me an example for the following function, so that I can try on my own for other functions as well

    <?php $posts = get_posts('numberposts=5&offset=8'); foreach($posts as $post) : setup_postdata($post); ?><li>................</li>
    <?php endforeach; ?>

    Or you can give a live example of wp-list-pages function.

    Hope for an early positive reply.

    Thansk,

    DG…

  • 72. Rob  |  June 15th, 2008 at 3:07 pm

    DG: The idea is simple: choose a key that uniquely identifies what you want to cache; use it to check if the data is already cached; if not go ahead and generate the data the slow way and also cache it with the key.

    e.g.: (untested)

    
    // the 'echo=0' returns the output instead of echoing it
    $args = 'exclude=1,3&echo=0';
    $key = 'wplp'.$args;
    $data = poc_cache_fetch($key);
    if (!$data) {
      $data = wp_list_pages($args);
      poc_cache_store($key, $data)
    }
    echo $data;
    

    I hope that gives you the idea.

  • 73. Rob  |  June 15th, 2008 at 3:19 pm

    Saadat: It could be a MySQL version issue but I can’t spot which queries might be at fault. Do you have access to your PHP error logs? That might give a clue. Meanwhile I’ll delve about a bit in the code.

  • 74. Saadat  |  June 16th, 2008 at 5:56 am

    Rob: Unfortunately, I don’t have access to PHP error logs since I use shared hosting. Though I did try to log any errors (using this script), but couldn’t find any entry from poc-cache.php.

  • 75. Jeff  |  August 10th, 2008 at 8:22 am

    I seem to have the same issues as Richard. Nothing is being written to the table. I can see the table being dropped & created no problem on activate/deactivate. I’m only trying to make it work with ‘Similar Posts’.

    WP 2.6
    POC 4.0.6

  • 76. Rob  |  August 10th, 2008 at 10:00 am

    Jeff: Do you have access to your PHP error log? If so could see if there are any errors specific to the cache plugin? That would be a good place to start hunting down this issue. Thanks.

  • 77. Jeff  |  August 11th, 2008 at 2:26 am

    Sadly nothing in the php error log about this plugin at all.

  • 78. Rob  |  August 11th, 2008 at 8:41 am

    Jeff: I’ve emailed you a version of the plugin with some debugging code included. Hopefully we will be enlightened.

  • 79. scribu  |  August 27th, 2008 at 4:30 pm

    Hello, I\’ve just started to use this plugin with two of your other plugins (Compact Archives and Blix Archives) and it looks promising.

    The problem is that when the post titles from the Blix Archives are cached, non-ASCI characters like \’Ĺź\’ and \’ĹŁ\’ turn into question marks.

    Is there any way to correct this?

  • 80. scribu  |  August 27th, 2008 at 4:43 pm

    I found out that if you just change line 108 in poc-cache-admin.php (version 4.0.6)

    from

    ) ENGINE = MyISAM;\";

    to

    ) ENGINE = MyISAM DEFAULT CHARSET=utf8;\";

    it solves the problem.

  • 81. Rob  |  August 27th, 2008 at 8:49 pm

    scribu: Thank you for the bug report … and thank you even more for finding the solution! I’ll make the change and release.

  • 82. Saadat  |  October 24th, 2008 at 11:36 am

    Hello Rob!

    I had previously left a comment (#68) about a problem with the POC plugin. My web host recently upgraded their PHP and MySQL setups, and the plugin is working prefectly fine now. I guess it really was a version issue, after all.

    Thanks again for your excellent work. :)

  • 83. Yin-YIn  |  November 9th, 2008 at 6:10 pm

    Hello!
    Your plugin is great!
    I’ve made the .po file in french but the translation doesn’t work because the function “load_text_domain” is not include. :(

    Can you make this change in your next versions?

    Regards…

  • 84. Enclave  |  July 4th, 2009 at 7:43 am

    Is this still being maintained?

  • 85. nonhocapito  |  July 4th, 2009 at 8:45 pm

    Hi. Fantastic plugin that I have been using for a while.

    Here’s my question, I have a function ready to strip the content of blockquote tags from the excerpt, just because I normally have a quote at the beginning of my posts that usually takes most of the whole thing.

    Is there a way to pass the output of this plugin through a filter so that I can apply my function? Having a custom plugin of mine on top of yours would be better than editing manually your files.