Index: wp-content/themes/twentyfourteen/functions.php
===================================================================
--- wp-content/themes/twentyfourteen/functions.php	(revision 25369)
+++ wp-content/themes/twentyfourteen/functions.php	(working copy)
@@ -369,45 +369,57 @@
 }
 
 /**
- * Filter the home page posts, and remove formatted posts visible in the sidebar from it
+ * Remove the posts visible in the sidebar from the blog home.
  *
  */
 function twentyfourteen_pre_get_posts( $query ) {
-	// Bail if not home, not a query, not main query.
-	if ( ! $query->is_main_query() || is_admin() )
+	// Bail if we're not on the blog home, if it is not the main query or if we are in the admin.
+	if ( ! $query->is_home() || ! $query->is_main_query() || is_admin() )
 		return;
 
-	// Only on the home page
-	if ( $query->is_home() ) {
-		$exclude_ids = array();
+	// Use the cached post IDs to exclude if they exist.
+	$cached_exclude_ids = get_transient( 'twentyfourteen_ephemera_to_exclude' );
 
-		$videos = twentyfourteen_get_recent( 'post-format-video' );
-		$images = twentyfourteen_get_recent( 'post-format-image' );
-		$galleries = twentyfourteen_get_recent( 'post-format-gallery' );
-		$asides = twentyfourteen_get_recent( 'post-format-aside' );
-		$links = twentyfourteen_get_recent( 'post-format-link' );
-		$quotes = twentyfourteen_get_recent( 'post-format-quote' );
+	if ( false !== $cached_exclude_ids ) {
+		$query->set( 'post__not_in', $cached_exclude_ids );
+		return;
+	}
 
-		foreach ( $videos->posts as $post )
-			$exclude_ids[] = $post->ID;
+	// Fetch the post IDs to exclude and cache them before use.
+	$widget_settings = get_option( 'widget_widget_twentyfourteen_ephemera' );
 
-		foreach ( $images->posts as $post )
-			$exclude_ids[] = $post->ID;
+	if ( false === $widget_settings )
+		return;
 
-		foreach ( $galleries->posts as $post )
-			$exclude_ids[] = $post->ID;
+	$exclude_ids = array();
 
-		foreach ( $asides->posts as $post )
-			$exclude_ids[] = $post->ID;
+	foreach ( $widget_settings as $setting ) {
+		if ( isset( $setting['format'] ) &&  isset( $setting['number'] ) ) {
+			$posts_to_exclude = new WP_Query( array(
+				'order'          => 'DESC',
+				'posts_per_page' => $setting['number'],
+				'no_found_rows'  => true,
+				'post_status'    => 'publish',
+				'post__not_in'   => get_option( 'sticky_posts' ),
+				'tax_query'      => array(
+					array(
+						'taxonomy' => 'post_format',
+						'terms'    => array( 'post-format-' . $setting['format'] ),
+						'field'    => 'slug',
+						'operator' => 'IN',
+					),
+				),
+				'fields'        => 'ids'
+			) );
 
-		foreach ( $links->posts as $post )
-			$exclude_ids[] = $post->ID;
+			if( isset( $posts_to_exclude->posts ) && ! empty ( $posts_to_exclude->posts ) ) {
+				$exclude_ids = array_merge( $exclude_ids, $posts_to_exclude->posts );
+			}
+		}
+	}
 
-		foreach ( $quotes->posts as $post )
-			$exclude_ids[] = $post->ID;
-
-		$query->set( 'post__not_in', $exclude_ids );
-	}
+	set_transient( 'twentyfourteen_ephemera_to_exclude', $exclude_ids );
+	$query->set( 'post__not_in', $exclude_ids );
 }
 add_action( 'pre_get_posts', 'twentyfourteen_pre_get_posts' );
 
Index: wp-content/themes/twentyfourteen/inc/widgets.php
===================================================================
--- wp-content/themes/twentyfourteen/inc/widgets.php	(revision 25369)
+++ wp-content/themes/twentyfourteen/inc/widgets.php	(working copy)
@@ -218,6 +218,7 @@
 	 */
 	function flush_widget_cache() {
 		delete_transient( $this->id );
+		delete_transient( 'twentyfourteen_ephemera_to_exclude' );
 	}
 
 	/**
