Posted on Mon, Sep 1st, 2008 | Categories: WordPress Plugin |

A high-performance cache plugin for WordPress, and a plus for WP-Cache or WP Super Cache !

Download

ChangeLog

Why we need this WP Widget Cache?

WP Widget Cache can cache the output of your blog widgets. Usually it will significantly reduce the SQL queries to your database and speed up your site.

I think you've heard of WP-Cache or WP Super Cache, they are both top plugins for WordPress, which make your site much faster and responsive. Here is how cache works:

"caching WordPress pages and storing them in a static file for serving future requests directly from the file rather than loading and compiling the whole PHP code and the building the page from the database".

If your site get a very high traffic, or you blog are hosted on a shared server, you do need cache. If you use widgets, you do need WP Widget Cache.

Why WP-Cache or WP Super Cache is not enough?

WP-Cache or WP Super Cache cache 'page', and WP Widget Cache cache 'widget' or your sidebar, that's the difference.

Let me explain this more clearly:

If some of your page is very popular, and people keep visit this page, then the page cache will be very helpful. But what if the user click some link and visit another page of your blog, or Google is crawing your whole site? Cache another whole page? Actually that's not necessary for most time. As we all know, WordPress share the same widgets, they're all the same, maybe on all the pages of your site. For example, the Categories widget, this maybe never change, the Archives widget, maybe changes once a month. So it's really really not that necessary to query the database again, especially when you use a lot of widgets.

WP Widget Cache is not to replace the WP-Cache or WP Super Cache, it's a plus for them, as it reducing the cost for caching a new page. you can set the cache time for each widget individually, seconds to years, whatever you like. For Categories widget, days maybe fine, for Recent Comments widget, seconds maybe fine.

How effective it is?

That depends on how many and what widgets you use, for this site, the queries for home page reduce from from 69 to 19, that's means 70% improvement.

Notice

There're some widgets that should not be cached!!

Some widgets are dynamic, that means they show different content in different conditions, for example, for different pages, for login / unlogin users.

If you use such dynamic widgets, don't worry, just left the cache expire time(see the screenshots) field empty or 0, which will prevent the WP Widget Cache to do anything.

Here's a list of such widgets to be finished, if you know something new, just leave a comment here.

  1. Lee

    This sounded great. I uploaded it, and all my widgets disappeared (in Firefox). Still interested in seeing it work. Any suggestions?

    Thanks… Lee

  2. Andrew

    Hi Lee,

    Disappeared? That is sound very serious. I use it myself, it works fine.

    So will you please check the cache folder under the WP Widget Cache pluglin folder, is there such a folder, and is there any files under it?

    Sorry for this.

  3. Andrew

    Oh, Lee, your site is running on PHP 4 or PHP 5 ?

  4. hi. Thanks for plugin

    perfect.

    Regards

  5. GBeans

    Thank you very much. I always worried about using more than a few plugins for site slowdown reasons.

  6. Andrew

    Hi Baron and Gbeans,

    I’m very glad to see you like this plugin.

    Thanks.

  7. bob

    I love this plugin。

  8. Andrew

    Hi Bob,

    Hope it’s useful to your blog.

  9. I will try to use this plugin….

  10. Andrew

    Thanks for your trying, Sapimoto.

    If having any issues, just tell me here.

  11. Leo

    Great plugin! but I go to themes -> widgets , see the “clear all widgets cache” button and “(” only.

  12. Matt

    The plugin sounds like a great idea, very logical. Not point reading the same info from the database again and again. Thanks for it, I will be sure to use it soon.
    Cheers

  13. Trying to stick to a minimalist/speedy design has always been my goal, and this plugin makes it all the easier! Thanks a lot buddy!

  14. Andrew

    Hi Leo,

    The source code of the button will be

    <input type=”submit” name=”widget_cache-clear” id=”widget_cache-options-submit” value=”Clear all widgets cache” /> (<num>)

    If you only see a “(”, I think it may be some style problem, please right click and see your page source, if the code are all right, then you can try some debuging.

    For Firefox, you can use Firebug, https://addons.mozilla.org/firefox/addon/1843,

    For IE, you can use IE Developer Toolbar, http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en

    These plugins will tell exactly the occupied areas of the button.

    Any issues, just leave a comment here.

  15. Andrew

    Hi Mart and Rishi,

    Very glad to see you like this plugin, and it’s helpful.

  16. Leo

    Thanks Andrew,
    I don’t know how to fix. I am using the wordpress 2.6.2 default admin interface and I’ll try to fix.

  17. Andrew, love the plugin, and thanks for your great work.

    Question: Do you know if there is any significant performance difference for caching widgets that are HTML-based? For example, I have a HTML widget that displays a 100% static Creative Commons license at the bottom, a mostly static HTML widget for ‘About Me’ (with only one line of PHP code to display my Dopplr status), and a search widget which I think is static.

    Should I bother to cache those?

  18. Andrew

    Hi Jonathan,

    Thanks for trying this plugin.

    There’s no need to cache static content, as cache itself is something static too.

  19. Andrew

    Oh Jonathan,

    I just visit your site, and I thought I should explain more clear.

    As far as I konw, the Search Form is the only widget that use a static file, it’s file ’searchform.php’ under your theme folder. The text widget, on the other side, will query the database to get the text content, so it’s not static, and should be cached.

    Any way, there’s no harm to cache a widget.

  20. Ahh… OK. That makes sense. Thanks.

  21. I use widget cache today,work perfect.Anyway i have little problem.My site use 3 column.So it have 2 siderbar.I try to use “auto expire these things changed” but it didn’t actually saved.More clearly like this
    On sider bar 1,after config,i save change,ok it saved,anyway when i go on sider bar 2 then config and saved.Tick box “auto expire these things changed” on sider bar 1 haven’t save anymore ?
    Sorry my bad english hope you can understand it ^.^!

  22. Andrew

    Hi Lordgoth,

    Yep, it’s a bug, I’ll release a new version later.

    Thanks for helping me improve this plugin:)

  23. Andrew

    Hi Lordgoth,

    I just released a new version 0.15.1, it should fix the bug.

    Thanks again:)

  24. Hi Andrew,

    I was the one who informed you about the issue with the MiniMeta Widget. Here’s what I just had to do to get your plugin to work with MiniMeta (so far).

    I went into the MiniMeta Widget. I took a print screen image of the settings. I could have written them down of course. Then I activated your plugin, set all the cache times, and saved. After the save, the MiniMeta Widget was empty again even though the cache time was left empty. I reset the MiniMeta settings and resaved. So far, it’s holding.

    One might want to deactivate MiniMeta before activating your plugin and then reactivate MiniMeta after setting all the cache times. That might work.

    Well, I thought I’d just give you an update. There is something in your plugin that is clearing the MiniMeta settings when the Widgets page is updated via the Save Changes button. It shouldn’t do that.

    Blessings to all,

    Tom Usher

  25. Andrew

    Hi Tom,

    Sorry for this issue.

    Actually I mentioned a werid thing in my last email to you. Please deactive WP Widget Cache first, that’ll make things clear. Then move the position of MiniMeta, up or down, then save. I found the settings are clear too. So is it possible there’s some bug with MiniMeta?

    Ok, please confirm this first, if without WP Widget Cache, MiniMeta works all fine, I’ll have a more careful look at the source code of both side.

    Thanks for helping me improve this plugin:)

    Regards,
    Andrew

  26. Thanks i just upgrade and test.It worked perfect now.Thanks for your hard work ^.^

  27. Andrew

    Hi lordgoth,

    Very glad to see it worked for you:)

  28. I love your widget and was using it but I have run into a problem with the upgrade process. I cannot use the automatic upgrade as it will not get rid of the old version so I tried to delete the old version using FTP but still no luck. Logged into cPanel and tried deleting using the file manager from there and still could not get rid of it.

    Any suggestions? I would like to upgrade and keep using the plugin.

  29. Andrew

    Hi Brian,

    Thanks for trying this plugin.

    Do you have problem with deleting the plug-in folder, likely to be ‘wp-widget-cache’? If so, you can try to update some files under the plugin folder, just two .php files, widget-cache.php, and inc/wcache.class.php. For the files under cache folder, please delete them all.

    Or you can try to rename the old plug-in folder, then reinstall.

    Let me know whether it’s helpful.

    Regards,
    Andrew

  30. Hey Andrew, I needed some clarification.

    I use WP-Super Cache (without the GZip) on my site in conjunction with WP-Widget Cache. Suppose that my super-cache expiration time is 3,000 seconds while my Statistics widget (controlled by Widget Cache) has an expiration of 2,000 seconds.

    If my main page has been super-cached and all the widgets have been cached at some time, let’s say time 0, and my statistics widget is set to expire in 2,000 seconds, will I have to wait for the super-cache page to expire in order to reflect changes in the statistics widget, or will the widget refresh EVEN THOUGH the entire page is still super cached?

    The reason I ask is because I love the Super Cache plugin serving static pages instead of having to requery the database everytime, but I would still like my widgets to refresh. Donncha (Super-Cache’s creator) has said that in order to do this, the widgets would have to be rewritten as Javascript (in other words, javascript widgets remain dynamic, even on super-cached pages).

  31. Andrew

    Hi Rishi,

    WP-Super Cache will cache an entire page to a static file, and WP Widget Cache will cache the output of Widget. If entire page is cached, then it will fetch the static page and return, no longer reach the widget output, so page cached is more high-priority, it stands in front of WP Widget Cache.

    Donncha is right, for page cache, javascript(maybe ajax) is the solution for leaving some part dynampic. Or we should use part cache(like only cache the post part, comment part, siderbar part), not entire page cache.

    I think I’ll think this requirement for the next version.

    Regards,
    Andrew

  32. Thanks for the quick response, buddy! That’s what I figured. Nevertheless, your plugin has a nice home in my corner of the Internet. :-)

  33. Conrad Erway

    I get the following message where my widgets used to be:

    Warning: Illegal offset type in /export/home/he/herita51/public_html/Wordpress/wp-content/plugins/wp-widget-cache/widget-cache.php on line 446

    Any suggestions?
    Thanks

  34. Conrad Erway

    It turns out the above occurred when i did not have any time inserted in the widgets. When I put in 3600 seconds all of my widgets disappeared.

  35. Hi Conrad,

    Please make sure your wordpress version is 2.5 or later. If so, I am not very sure how could this happen, but I think you can help debug this.

    /wp-content/plugins/wp-widget-cache/widget-cache.php, I need you to replace this file with this one, http://www.mashget.com/widget-cache.zip

    Then please try again to see if it’s OK for display.

    I think you may miss some widgets, then you can look at the page source to find this:

    <!–WGC Error

    Please tell me what you got.

  36. Conrad Erway

    Andrew,

    My Widgets still do not appear. I am running Wordpress 2.6.2. I do not see the WGC Error message any where in the source code. I am using only two widgest at this time, Text and Events Calendar. I am also using SuperCache.

  37. Hi Conrad,

    Once there’s a warning msg, when you left the time field empty, right?

    Warning: Illegal offset type in /export/home/he/herita51/public_html/Wordpress/wp-content/plugins/wp-widget-cache/widget-cache.php on line 446

    Please debug in this situation.

    Sorry for this trouble.

    Andrew

  38. Conrad Erway

    Andrew,

    I did as suggested: I uploaded the new widget-cache.php file and removed the time from the widget time fields. The results was the following message:

    Warning: Illegal offset type in /export/home/he/herita51/public_html/Wordpress/wp-content/plugins/wp-widget-cache/widget-cache.php on line 452

    Conrad

  39. HI Conrad,

    I really confused about this issue:(

    I just googled the waring msg, and I got this: http://weblog.kreny.com/archives/2004/12/troubleshooting.html, basically it said maybe the Zend Optimizer version was too old, but as the entry was in 2004, very old too, likely not helpful.

    Truly sorry for this.

    Regards,
    Andrew

  40. Jan

    This is just awesome! Great plugin.

    Thanks for making it available!

  41. Conrad Erway

    Andrew,

    That may be the problem, In my case, I find that I am running PHP 4.4.4 with Zend engine v1.3.0 . My site gives me the following info re the Zend engine:
    This program makes use of the Zend Scripting Language Engine:
    Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with eAccelerator v0.9.5, Copyright (c) 2004-2006 eAccelerator, by eAccelerator with Zend Extension Manager v1.0.9, Copyright (c) 2003-2005, by Zend Technologies with Zend Optimizer v2.6.0, Copyright (c) 1998-2005, by Zend Technologies

    Regards

  42. Hi Jan,

    Vary glad you like this plugin:)

  43. Hi Conrad,

    Zend Optimizer v2.6.0 is not that old, as the entry mentioned, 2.5.7 would solved the waring msg. Still no idea:(

    Regards,
    Andrew

  44. Great blog. I like layout!!!!

  45. Thanks, meacroncorser :)

  46. Hi,
    Nice work. Are you planning a wp-mu version of this plugin?

    I mean a centralized control for widgets by wpmu admin. I need sitewide cache properties for widgets.

  47. Or simplest way: is there a way to install this widget by sitewide defaults.

  48. Hi Satranc,

    I should admit that I’m not very familiar with mu yet, but I do plan to.

  49. Danny

    Thanks for an excellent plugin, Andrew.

    One to add to your list of widgets that should not be cached:
    Calendar widget (that comes with WP)

    If you ever figure a solution for that one, please let me know as it has an overhead of 3 DB queries.

    Looking forward to your next GREAT CREATION !!

    Thanks,
    Dan

  50. Hi Danny,

    Thanks for trying this plugin:)

    About Calendar widget, I do missing something, as if cached, when Nov.1th camed, it might still be Oct.31th, it’s this reason, right?

  51. Sly

    Hi
    After i used this plugin, my RSS feeds are not updating. Same in dashboard. The RSS feed from wordpress display same articles for 3 days, and nothing changes.
    Why?

  52. Hi Sly,

    This plugin will just cache the widget for a period of time, I don’t get how could it affect the dashboard rss. But I think you can try to de-active this plugin, and then check whether the feed was updating.

  53. Sly

    Sure. It’s deactivated.
    And nothing hapend.
    The dashboard news remain unchaged, and some of RSS feeds from website are still unchanged.

  54. Hi Sly,

    If this plugin is deactived, then it’ll not affect the wp anymore, so if the rss remain unchanged, it must be something else.

  55. upgraded the plugin today, and now it gives these errors:

    Warning: mkdir() expects at most 2 parameters, 3 given in /home/quick42/public_html/biblemoneymatters/wp-content/plugins/wp-widget-cache/inc/wcache.class.php on line 84

    Warning: fopen(/home/quick42/public_html/biblemoneymatters/wp-content/widget-cache/acc395808606926b0dd1738785822e0e/acedd2fbf7e7ffdb8f4738d4b6475d9b) [function.fopen]: failed to open stream: No such file or directory in /home/quick42/public_html/biblemoneymatters/wp-content/plugins/wp-widget-cache/inc/wcache.class.php on line 142

    Warning: flock(): supplied argument is not a valid stream resource in /home/quick42/public_html/biblemoneymatters/wp-content/plugins/wp-widget-cache/inc/wcache.class.php on line 143

    Warning: fclose(): supplied argument is not a valid stream resource in /home/quick42/public_html/biblemoneymatters/wp-content/plugins/wp-widget-cache/inc/wcache.class.php on line 148

  56. I like Your Plugin - but the last update went wrong…..

    Warning: mkdir() expects at most 2 parameters, 3 given in /home/……………………..wp-widget-cache/inc/wcache.class.php on line 84

    I had to deactivate the cache

    Christian

  57. I’m having the same issue as Peter and Christian and had to revert to the previous version.

  58. Hi Steve, Christian, Peter,

    I’m so sorry for this. The reason is you’re using php 4, and the function mkdir accept the 3rd param since php 5, I should have thought of this.

    I’ve just release a new version 0.25.1, please update.

    Regards,
    Andrew

  59. thank you - it works perfect!

    Christian

  60. Thank you for fixing this so quick Andrew!

  61. I mentioned above that my problem was fixed, and the original problem WAS fixed.

    Today I wrote a post and hit the save button from this page: http://www.yourwebsite.com/wp-admin/post.php?action=edit&post=1613

    Instead of saving as it normally does, today it refreshed to a blank Page:

    http://www.yourwebsite.com/wp-admin/post.php

    The same thing happens when i try to publish the post - it just goes to the blank page:

    http://www.yourwebsite.com/wp-admin/post.php

    I deactivated the widget cache plugin, and the save/publish features work again.

    Can you look into that and see why the plugin might be causing this problem?

  62. Hi Peter,

    I’ve no idea about how could cause such a problem, is there any ‘error_log’ in your web root folder or the wp widget cache plugin folder, that might help me figure out why.

    Regards,
    Andrew

  63. Hi.

    Wanted to let you know I encountered the same exact issue as Pete and reached the same resolution by deactivating the new upgraded plugin. Not sure how I can help resolve the issue.

    Jeremy

  64. Hi Jeremy,

    Is there any error_log in your wp-admin folder?

    Also, please tell me, whether you use the ‘auto expire options’, and check ‘posts’, I think it might have something with this.

    Regards,

  65. Hi Andrew,

    I don’t have an error_log but I too I’m having the same issue as Pete and Jeremy. I resolved it by deactivating the plugin.

    I did have the expire option set to 3600 and had posts checked in several widgets that needed to be updated when posts are. I also had tags checked in my tag cloud and categories checked in my category cloud widget. When saving a post it had a lot of problems with the categories, checking off categories that weren’t checked and not saving all the tags that were added to the post. I hope this information helps.

  66. no error log in there.. i had the expire options set to either 0 or high numbers, higher than 3600. i didn’t check to auto expire.

  67. Hi Pete, Steve,

    I can’t find the reason, I’ve left the msg on http://wordpress.org/support/topic/220033, hope someone might help us.

  68. I have exactly the same problem as Pete!
    And when i write a page or a post, every time WP saves automatically, it produces a new post or page, that can’t be deleted if the plugin activated…?
    Turn off the plugin -> things work fine.

  69. Hi Friedel,

    There’s been 4 users telling me that having the same problem as you, but I can’t replicate this error or find the reason. I’ve left the message on http://wordpress.org/support/topic/221283 , hoping someone might help us.

    Before this issue solved, I think you can use an older version, http://downloads.wordpress.org/plugin/wp-widget-cache.0.22.1.zip, if you think the update notice is boring, please edit the ‘widget-cache.php’, changing the 7th line to ‘Version: 0.25.1.1?.

    Regards,
    Andrew

  70. I’ve gone back to using the old version until /if when the new one gets an update. Thanks for your hard work - love the plugin - just want it to work correctly with my blog for the new version! thanks!

  71. hi and thx for this plugin!!
    I have one little question. step 3 of the installation “make sure the subfolder ‘cache’ is writable”. Which subfolder??? Do i have to create one? In the /plugins/wp-widget-cache directory??

    I just asked because after installation no cache subfolder was created … and so i think the plugin don´t work right now :(

    greetings,
    thomas

  72. Hi Thomas,

    The installation was for the version before 0.25(I’ll update this later), the cache folder is now move to /wp-content/widget-cache.

    Also if you want to know the widget cache works or not, you can have a look at the source of the page, and search ‘<!–WP Widget Cache End –>’. If no such string, the widget cache might not work properly.

    Any problems, just tell me. Thanks.

    Regards,
    Andrew

  73. @ Andrew, I had a similar problem as the other people with not being able to write/edit pages, but writing posts was working just fine. Deactivating widget cache fixed the problem. I left a message on the support forum topic you link to above as well.

  74. Hi Andrew,
    thanks for your reply, i still had the 0.22.1 on my HDD, so there was no problem to get it back to work… :)
    Thanks for the Tip with the 7th line!

    Season’s Greetings!

  75. Aouni

    Hello Andrew. I liked this plugin very much, although I would liked it to work with Widget Logic. I have some widgets which appear on my blog homepage only, but when I install Wp Widget Cache, the widgets appear everywhere.

    Is there a way to solve this and make it work with Widget Logic?
    Thank you.

  76. Hi Aouni,

    Widget cache can’t work with widget logic for one widget at the same time.

    For the moment, you should leave the expire time field empty for that widget, so the widget cache will not cache that widget.

    Regards,
    Andrew

  77. Aouni

    Hey, thank you Andrew, I did what you’ve said and I got to decrease my queries by 5. Better than nothing ;]

    Sorry, am not an advanced developer, should I consider these 5 queries a big deal?

    P.S. I got decrease down sql queries in my blog from 72 to 37 at first with PHP Speady plugin, and not it has become 32 with widget cache.

    Thanks a lot.

  78. This plugin doesn’t seem to work at all for me. I have a scary 104 queries per page on my site, and I’m sure it’s because of the plugins. I just upgraded to Wordpress 2.7 and installed WP Widget Cache 0.25.1. After activating the plugin, I don’t see any changes at all in the site. Also, I don’t see where I can configure Widget Cache to act on the widgets.

    On the Appearance -> Widgets Screen, when I scroll down, I see this button, but the HTML is all weird:

    WP Widget Cache Options

    When I look at the widget-cache directory, I see a few files, but they are all 41 bytes long and just have this info in it:

    a:2:{i:0;a:0:{}s:10:”__output__”;s:0:”";}

    So, this is not having any impact for me…. help!

  79. Hi Rex,

    Please have a look at the http://wordpress.org/extend/plugins/wp-widget-cache/screenshots/ , and if you can’t see the ‘expire in’ field, please check the settings->wp widget cache to make sure this plugin is turned on.

    Regards,
    Andrew

  80. Thanks — that worked, but you might want to update your screenshots, since they are not valid in Wordpress 2.7.

    Also, how do I force a part of my page to cache that’s not formally a widget? I have a portion of my theme that seems to make a lot of calls to the database that should be cached…. how can I use Widget cache to cache that part of the page? (I.e. treat it as if it was a widget?)

    Happy holidays!

  81. Another question: I am having the same problem that others mentioned where I have 2 sidebars, but the expiration information for widgets in Sidebar #2 is not saving… was this fixed?

  82. Hi Rex,

    If you want to cache some part of your page that is not a widget, you should write some code yourself, first you should figure out the part on the page, then find the code that generate this part, then cache the code. Widget cache use the cache class from Dragan Bosnjak(http://www.phpclasses.org/browse/package/3807.html), it’s very easy to use.

    The problem about cache mutiple sidebars have a fix since 0.15.1, if you still got this problem, will you please provide more details, the expiration cleared?

    Regards,
    Andrew

Leave a Reply