WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
fetch_feed() breaking caching (6 posts)

  1. JowiM
    Member
    Posted 1 year ago #

    Hi,

    I have noticed that a number of our pages are not being saved in the cache directory ('wp-content/cache/page_enchanced/url/') and consequently the pages are re-generated on every request. All these pages have in common is the use of fetch_feed() to list items from different blogs. When I commented out the fetch_feed() function the cache works correctly. I also tried enabling 'Cache feeds', but it did not solve the issue.

    Is any one experiencing this issue? or is just a configuration problem?

    We are using W3 Total Cache 0.9.2.8 and WP 3.5.1.

    Thanks

    http://wordpress.org/extend/plugins/w3-total-cache/

  2. Super Interactive
    Member
    Posted 1 year ago #

    Same here, this has been occurring since we updated to the latest version.

    Pages on one of our projects aren't being cached when they contain a widget that uses fetch_feed.

  3. Super Interactive
    Member
    Posted 1 year ago #

    I created a work-around by caching the feed as a transient. So instead of:

    $feed = fetch_feed( $feed_url );

    You would do:

    // Require for dealing with feeds
    require_once ( ABSPATH . WPINC . '/class-feed.php' );
    
    // Check if feed transients exists
    if( false === $feed = get_transient( 'foo_transient_key' ) ) {
    
       // If not, fetch it
       $feed = fetch_feed( $feed_url );
    
       // Store as transient for 4 hours
       set_transient( 'foo_transient_key', $feed, 4*60*60 );
    }
    
    // You now have an object $feed just like you did before

    Now you'll only fetch the feed once every 4 hours, and W3TC will cache your page the rest of the time.

    This seems to fix the problem. I always thought fetch_feed does its own transients/caching though. Either way, it's still weird W3TC skips entire pages for one simple fetch.

  4. Frederick Townes
    Member
    Plugin Author

    Posted 1 year ago #

    I can't see anything that would cause cache to fail with fetch_feed. Could you please submit a bug submission form from the support tab of the plugin?

  5. Super Interactive
    Member
    Posted 1 year ago #

    Done!

  6. JowiM
    Member
    Posted 1 year ago #

    @Frederick Townes. I have also submitted a bug report.

    @Super Interactive. Thanks for your solution it worked great

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic