all repos — wp-ffpc @ bdcae2f62f6c2b31f75af525e79409bfdc563733

Added new invalidation method: post/page + posts index page.

Clears cache for modified post/page. Also clears posts index page if content of type 'post' was changed.
Anton Pelesˌev anton.peleshev@zeroturnaround.com
Fri, 22 Aug 2014 17:27:23 +0300
commit

bdcae2f62f6c2b31f75af525e79409bfdc563733

parent

14b1d416d115130c7f48186d9383e598279058f8

2 files changed, 26 insertions(+), 1 deletions(-)

jump to
M wp-ffpc-backend.phpwp-ffpc-backend.php

@@ -221,6 +221,17 @@ /* this will only clear the current blog's entries */

$this->taxonomy_links( $to_clear ); } + /* clear pasts index page if settings requires it */ + if ( $this->options['invalidation_method'] == 3 ) { + $posts_page_id = get_option( 'page_for_posts' ); + $post_type = get_post_type( $post_id ); + + if ($post_type === 'post' && $posts_page_id != $post_id) { + $this->clear($posts_page_id, $force); + } + } + + /* if there's a post id pushed, it needs to be invalidated in all cases */ if ( !empty ( $post_id ) ) {
M wp-ffpc-class.phpwp-ffpc-class.php

@@ -140,6 +140,7 @@ $this->select_invalidation_method = array (

0 => __( 'flush cache' , $this->plugin_constant ), 1 => __( 'only modified post' , $this->plugin_constant ), 2 => __( 'modified post and all taxonomies' , $this->plugin_constant ), + 3 => __( 'modified post and posts index page' , $this->plugin_constant ), ); /* map of possible key masks */

@@ -483,7 +484,20 @@ <dd>

<select name="invalidation_method" id="invalidation_method"> <?php $this->print_select_options ( $this->select_invalidation_method , $this->options['invalidation_method'] ) ?> </select> - <span class="description"><?php _e('Select cache invalidation method. <ol><li><em>flush cache</em> - clears everything in storage, <strong>including values set by other applications</strong></li><li><em>only modified post</em> - clear only the modified posts entry, everything else remains in cache</li><li><em>modified post and all taxonomies</em> - removes all taxonomy term cache ( categories, tags, home, etc ) and the modified post as well</li></ol>', $this->plugin_constant); ?></span> + <div class="description"><?php _e('Select cache invalidation method.', $this->plugin_constant); ?> + <ol> + <?php + $invalidation_method_description = array( + 'clears everything in storage, <strong>including values set by other applications</strong>', + 'clear only the modified posts entry, everything else remains in cache', + 'removes all taxonomy term cache ( categories, tags, home, etc ) and the modified post as well<br><strong>Caution! Slows down page/post saving when there are many tags.</strong>', + 'clear cache for modified post and posts index page' + ); + foreach ($this->select_invalidation_method AS $current_key => $current_invalidation_method) { + printf('<li><em>%1$s</em> - %2$s</li>', $current_invalidation_method, $invalidation_method_description[$current_key]); + } ?> + </ol> + </div> </dd> <dt>