Viewing 3 replies - 1 through 3 (of 3 total)
  • I wish there was a clear cache for each widget.

    At the moment, I use WP-Optimize primarily for maintaining database. It has an option too for clearing transients, all at one go though. Works for my number of posts per category updates of course.

    The cache is not automatically invalidated on new posts or anything else.

    The cache time is 12 minutes per block and can be filtered in PHP using widget_output_cache_ttl.

    As is, the only reliable way to clear the cache is to delete all transients.

    Hope that helps.

    Plugin Author Kaspars

    (@kasparsd)

    All widget cache is invalidated every time you update any of the widgets.

    You can also do it from the code by bumping the “cache-widgets-version” option value (code example), like so:

    add_action( 'init', 'widget_cache_register_bump' );
    
    function widget_cache_register_bump() {
    
    	// Invalidate widget cache during these action calls
    	$purge_actions = array(
    		'clean_post_cache',
    		'edit_term',
    		'publish_post',
    		'comment_post',
    		'delete_comment',
    		'edit_comment',
    		'delete_post',
    		'edit_post',
    		'wp_update_nav_menu',
    		'activated_plugin',
    		'deactivated_plugin',
    		'wp_maybe_auto_update'
    	);
    
    	foreach ( $purge_actions as $action ) {
    		add_action( $action, 'widget_cache_do_bump' );
    	}
    
    }
    
    function widget_cache_do_bump() {
    	update_option( 'cache-widgets-version', time() );
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I invalidate the cache?’ is closed to new replies.