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.
This commit is contained in:
Anton Pelešev 2014-08-22 17:27:23 +03:00
parent 14b1d416d1
commit bdcae2f62f
2 changed files with 26 additions and 1 deletions

View file

@ -221,6 +221,17 @@ class WP_FFPC_Backend {
$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 ) ) {

View file

@ -140,6 +140,7 @@ class WP_FFPC extends PluginAbstract {
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 @@ class WP_FFPC extends PluginAbstract {
<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>