Support » Plugin: Twitter Widget Pro » [Plugin: Twitter Widget Pro] Tweets not updating (hosting incompatibility with TLC Transients)

  • Ross Wintle


    Hi there,

    I’ve had problems with numerous installs of Twitter Widget Pro not updating tweets and I’ve discovered – I think – that it’s all down to a problem with my hosting and your use of TLC Transients. This MAY (or may not) also be the cause of other people’s lack of updates.

    The behaviour I was seeing was that I appeared to have different versions of my tweet stream “cached” and I could flick between the different cached versions by changing the settings. So, for example, with lot of widget settings I might see Tweets A, B and C. With a different set of widget settings I would see Tweets C, D and E. Changing the widget’s settings between the two brought up to two different cached lists. BUT…when I posted a new Tweet NEITHER cached list of Tweets got updated.

    I checked the database and noted a few timestamps in transient values in there and then went and checked the code.

    TWP uses a hash of the widget options as a key for the transient “cache” of fetched Tweets. See line 710 of the plugin in the _getTweets function:

    $key = 'twp_' . md5( $this->_getFeedUrl( $widgetOptions ) );

    So that explains why different Tweet settings have different cached lists of Tweets, and how I can switch between them.

    But why are they never updating?

    Well, I’ve not done a too-thorough inspection of the code but TLC transients seems to use a “loopback” URL to fetch the cached list of Tweets without holding up the user – similar to how WP-Cron works. When scheduled it does:

    add_action( 'shutdown', array( $this, 'spawn_server' ) );

    And the spawn_server callback looks like this:

    public function spawn_server() {
    			$server_url = home_url( '/?tlc_transients_request' );
    			wp_remote_post( $server_url, array( 'body' => array( '_tlc_update' => $this->lock, 'key' => $this->key ), 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters( 'https_local_ssl_verify', true ) ) );

    NOW…my hosting company don’t actually allow me to make these loopback HTTP requests. So, all my installed instances of TWP are broken.

    Options for me seem to be:
    1) The TWP developer make use of TLC Transients optional
    2) I could put some hack in that deletes the transients every now and then. I DO have WP-Cron working (via a Unix cron job), so I could setup a job to clear the transients from the database using that.
    3) I could use another plugin.

    I know that TLC Transients is a clever way of making some big efficiencies. And I know that my hosting issue is probably a rare thing. But I could really use some feedback on whether TLC Transients will continue to be used or not, or if I have to consider one of the other options.

    I hope that write up is useful to someone else too.


Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Aaron D. Campbell


    My immediate reaction is to say “find a better host”. I mean that sincerely.

    The truth is that TLC Transients gives a nice boost both in efficiency AND in reliability. There are a small percentage of people that are having problems, but writing and maintaining the code to keep this as an option seems like an awful lot of effort that I’d prefer to avoid.

    Having said that, let me think on this a bit and see if I can come up with a quality solution.

    Ross Wintle


    Hi Aaron,

    Thanks for the quick response.

    On balance my host are actually VERY good. I’ve shopped around and tried different companies but they really are excellent. I will re-address this with them though as their policy does seem to break WordPress – and probably other CMS’ too.

    I can see the benefits of TLC Transients, and I can see why you wouldn’t want to put a load of effort in to make things work for a small percentage of users.

    I’m keen to help get this working though. I’ve invested quite a lot of time in styling TWP for various sites so for me the trade off might be helping re-work TWP vs re-working all my CSS for another plugin.

    And there may be another, simpler, but less efficient way!

    TLC Transients seems to have a ‘force_background_updates’ option. Perhaps it also needs a ‘suppress_background_updates’ option. If I can patch TLC Transients to add this then perhaps making an option in TWP is simpler?

    Ross Wintle


    Hi Aaron,

    OK, I think I’ve cooked up a version that will work for people experiencing this issue. It’s not as efficient at fetching Tweets as it does this “live” rather than as a background task, but it only refreshes Tweets every 5 minutes.

    It can be invoked by changing your tlc_transient call in _getTweets to:

    return tlc_transient( $key )
    			->expires_in( 300 ) // cache for 5 minutes
    			->updates_with( array( $this, 'parseFeed' ), array( $widgetOptions ) )

    So all that’s left to do is include an option in your default settings meta box and then make the correct tlc_transient call depending on that option.

    Are you happy with me zipping up what I’ve done so far and releasing to people who have this issue?

    Plugin Author Aaron D. Campbell


    Are you happy with me zipping up what I’ve done so far and releasing to people who have this issue?

    That’sthe beauty of the GPL! You are more than welcome to release what you have.

    Ross Wintle


    Of course.

    I’ve done this in a bit of a hurry, so feedback welcome on my modification/contribution.

    My change may not get added but I also submitted a Pull Request to Mark Jaquith for TLC Transients to add a “prevent-background-updates” option.

    I can see why you might think it’s a bit daft using TLC transients and then having an option to turn off the background updates and lose all the efficiency, but it saves a plugin writer using TLC Transients writing two lots of transient-handling code.

    I’ve uploaded a modified version of v2.3.8 to my website here if anyone wants to give it a try.

    Thanks heaps magicroundabout! your 2.3.8mod is working for me!

    @aaron – I just need to keep my client happy – I’m subscribed to this thread, and would be happy to help testing updates you may release..

    for the record, my host allows http loopback connections (essential for backup buddy!)

    tx, Tim

    @aaron — Telling people to STFU and find a better host isn’t really very helpful. I’m having this problem on a Rackspace site…

    Much more helpful would be info on how to fix HTTP loopback requests if a user has full access to their server’s /etc directory.

    @magicroundabout — I’ll try your version later today and post feedback.

    Anyone who arrives at this issue and can edit /etc/hosts, try this:

    1. Open your server’s /etc/hosts file in a text editor.
    2. Add the following line (anywhere works, though after the line with “localhost” generally is best.):
    3. Save.

    Worked for me, anyway.

    The other option, if you can’t edit /etc/hosts and aren’t willing to upgrade to a host that will let you do so, is to email your host asking WTF not. Aaron, given the number of issues open with this exact problem (Note that many users who have a problem won’t post an issue, but simply think your plugin’s broken and try a different one. Think about the 1-10-100 rule — if you have 20 different people post about this issue, the reality is that probably >200 have experienced it.), and you’re dead-set against changing away from TLC Transients, it might be worthwhile to write a canned letter for users to send to their ISPs, kind of like what BackupBuddy has for users without command-line zip libraries.

    For the record, I have the same issue on both ICDSoft and Zenutech hosting. magicroundabout’s fix works for me.

    Hello all.
    Sorry to be a thread necro, but the ->prevent_background() addition does not seem to work with version 2.4.1. It breaks the plugin and the twitter box will not show. I’ve tried adding both flush_widget_cache() and wp_cache_delete( ‘widget_twitter_widget_pro’, ‘widget’ ) to clear the cache and force the plugin to grab fresh content, but that was to no avail. Does anyone else have any ideas on how to disable the caching portion of the code? I am unable to try the hosts file hack.

    Plugin Author Aaron D. Campbell


    ->prevent_background() doesn’t actually exist. You’d need to add it similar to this:

    Having said that, it’s really not a good idea. You should get your server configured so that it works instead. Read more here:


    Thanks for the response. I agree with your statement, however, I am not the one that makes that call. I was only tasked with getting the twitter plugin working. I’m not sure that this is my solution as I was unable to get wordpress to even clear the plugins cache as mentioned previously, but it was able to pull the feeds the first time so I’m hoping I can pull them again. Thanks again for this plugin.


    I just came across this thread as the tweets on a site I was working on weren’t updating correctly. I got worried reading the above as my client’s host doesn’t allow the http loopback connections and so to use backupbuddy I have to change the config file to include the define(‘ALTERNATE_WP_CRON’, true); line.

    Anyway, that’s off topic, I just went into Twitter Widget Pro settings and noticed the Use Twitter API via HTTPS / Use Twitter API via HTTP options, mine was set to https, I changed to http and now it is updating properly.

    So that simple change might help some people out with the same problem.

    Is that all part of your update magicroundabout?

    Eitherway, all working now so happy days 🙂

    correction to the above, that worked and made it refresh after the change, but it hasn’t refreshed since 🙁

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: Twitter Widget Pro] Tweets not updating (hosting incompatibility with TLC Transients)’ is closed to new replies.