all repos — wp-ffpc @ 0356107ea71d897b9fb7594a5886af9d6a3c5648

1.7.0 alpha
Peter Molnar hello@petermolnar.eu
Fri, 19 Sep 2014 09:38:54 +0100
commit

0356107ea71d897b9fb7594a5886af9d6a3c5648

parent

49c4da89f9b2d8eb61a9551acb9eea6c04bbcc0c

5 files changed, 69 insertions(+), 119 deletions(-)

jump to
M readme.txtreadme.txt

@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC

Tags: cache, page cache, full page cache, nginx, memcached, apc, speed Requires at least: 3.0 Tested up to: 4.0 -Stable tag: 1.6.4 +Stable tag: 1.7.0 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html

@@ -34,17 +34,21 @@ * pingback HTTP header preservation

* talkative log for [WP_DEBUG](http://codex.wordpress.org/WP_DEBUG "WP_DEBUG") * multiple memcached upstream support * precache ( manually or by timed by wp-cron ) +* varying expiration time for posts, taxonomies and home + Many thanks for donations, contributors, supporters, testers & bug reporters: -* [Harold Kyle](https://github.com/haroldkyle "Harold Kyle") -* [Eric Gilette](http://www.ericgillette.com/ "Eric Gilette") -* [doconeill](http://wordpress.org/support/profile/doconeill "doconeill") -* [Mark Costlow](mailto:cheeks@swcp.com "Mark Costlow") -* [Jason Miller](mailto:jason@redconfetti.com "Jason Miller") +* [Harold Kyle](https://github.com/haroldkyle) +* [Eric Gilette](http://www.ericgillette.com/) +* [doconeill](http://wordpress.org/support/profile/doconeill) +* Mark Costlow +* Jason Miller * [Dave Clark](https://github.com/dkcwd "Dave Clark") * Miguel Clara * [plescheff](https://github.com/plescheff) +* [CotswoldPhoto](http://wordpress.org/support/profile/cotswoldphoto) +* [tamagokun](https://github.com/tamagokun) == Installation ==

@@ -105,6 +109,13 @@

* every A. indicates BIG changes. * every .B version indicates new features. * every ..C indicates bugfixes for A.B version. + += 1.7.0 = +*2014-09-19* + +* **dropped Xcache support**, the reasons behind this is the outstandingly terrible documentation of Xcache +* added varying expiration time options + = 1.6.4 = *2014-09-12*
M wp-ffpc-acache.phpwp-ffpc-acache.php

@@ -52,6 +52,7 @@ /* plugin config not found :( */

else return false; +/* check for cookies that will make us not cache the content, like logged in WordPress cookie */ if ( isset($wp_ffpc_config['nocache_cookies']) && !empty($wp_ffpc_config['nocache_cookies']) ) { $nocache_cookies = array_map('trim',explode(",", $wp_ffpc_config['nocache_cookies'] ) );
M wp-ffpc-backend.phpwp-ffpc-backend.php

@@ -160,15 +160,32 @@

/* log the current action */ $this->log ( sprintf( __translate__( 'set %s expiration time: %s', $this->plugin_constant ), $key, $this->options['expire'] ) ); + /* expiration time based is based on type from now on */ + /* fallback */ + $expire = $this->options['expire']; + + if ( is_home() || is_feed() ) + $expire = $this->options['expire_home']; + elseif ( is_tax() || is_category() || is_tag() || is_archive() ) + $expire = $this->options['expire_taxonomy']; + + if ( empty($expire) ) + return false; + /* proxy to internal function */ $internal = $this->proxy( 'set' ); - $result = $this->$internal( $key, $data ); + $result = $this->$internal( $key, $data, $expire ); /* check result validity */ if ( $result === false ) $this->log ( sprintf( __translate__( 'failed to set entry: %s', $this->plugin_constant ), $key ), LOG_WARNING ); return $result; + } + + + public function clear_ng ( $new_status, $old_status, $post ) { + $this->clear ( $post->ID ); } /**

@@ -512,8 +529,8 @@ * @param mixed $data Data to set

* * @return boolean APC store outcome */ - private function apc_set ( &$key, &$data ) { - return apc_store( $key , $data , $this->options['expire'] ); + private function apc_set ( &$key, &$data, &$expire ) { + return apc_store( $key , $data , $expire ); }

@@ -598,8 +615,8 @@ * @param mixed $data Data to set

* * @return boolean APC store outcome */ - private function apcu_set ( &$key, &$data ) { - return apcu_store( $key , $data , $this->options['expire'] ); + private function apcu_set ( &$key, &$data, &$expire ) { + return apcu_store( $key , $data , $expire ); }

@@ -636,106 +653,6 @@ }

/*********************** END APC FUNCTIONS ***********************/ - /*********************** XCACHE FUNCTIONS ***********************/ - /** - * init apc backend: test APC availability and set alive status - */ - private function xcache_init () { - /* verify apc functions exist, apc extension is loaded */ - if ( ! function_exists( 'xcache_info' ) ) { - $this->log ( __translate__('XCACHE extension missing', $this->plugin_constant ) ); - return false; - } - - $xcache_admin = ini_get ( 'xcache.admin.user' ); - $xcache_pass = ini_get ( 'xcache.admin.pass' ); - - if ( empty( $xcache_admin ) || empty( $xcache_pass ) ) { - $this->log ( __translate__('XCACHE xcache.admin.user or xcache.admin.pass is not set in php.ini. Please set them, otherwise the use cache part of xcache is not accessible.', $this->plugin_constant ) ); - return false; - } - - /* verify apc is working */ - $info = xcache_info(); - if ( !empty( $info )) { - $this->log ( __translate__('backend OK', $this->plugin_constant ) ); - $this->alive = true; - } - } - - /** - * health checker for Xcache - * - * @return boolean Aliveness status - * - */ - private function xcache_status () { - $this->status = true; - return $this->alive; - } - - /** - * get function for APC backend - * - * @param string $key Key to get values for - * - * @return mixed Fetched data based on key - * - */ - private function xcache_get ( &$key ) { - if ( xcache_isset ( $key ) ) - return xcache_get( $key ); - else - return false; - } - - /** - * Set function for APC backend - * - * @param string $key Key to set with - * @param mixed $data Data to set - * - * @return boolean APC store outcome - */ - private function xcache_set ( &$key, &$data ) { - return xcache_set( $key , $data , $this->options['expire'] ); - } - - - /** - * Flushes APC user entry storage - * - * @return boolean APC flush outcome status - * - */ - private function xcache_flush ( ) { - return xcache_clear_cache(XC_TYPE_VAR); - } - - /** - * Removes entry from APC or flushes APC user entry storage - * - * @param mixed $keys Keys to clear, string or array - */ - private function xcache_clear ( &$keys ) { - /* make an array if only one string is present, easier processing */ - if ( !is_array ( $keys ) ) - $keys = array ( $keys => true ); - - foreach ( $keys as $key => $dummy ) { - if ( ! xcache_unset ( $key ) ) { - $this->log ( sprintf( __translate__( 'Failed to delete XCACHE entry: %s', $this->plugin_constant ), $key ), LOG_WARNING ); - //throw new Exception ( __translate__('Deleting APC entry failed with key ', $this->plugin_constant ) . $key ); - } - else { - $this->log ( sprintf( __translate__( 'XCACHE entry delete: %s', $this->plugin_constant ), $key ) ); - } - } - } - - /*********************** END XCACHE FUNCTIONS ***********************/ - - /*********************** MEMCACHED FUNCTIONS ***********************/ /** * init memcached backend

@@ -845,8 +762,8 @@ * @param string $key Key to set with

* @param mixed $data Data to set * */ - private function memcached_set ( &$key, &$data ) { - $result = $this->connection->set ( $key, $data , $this->options['expire'] ); + private function memcached_set ( &$key, &$data, &$expire ) { + $result = $this->connection->set ( $key, $data , $expire ); /* if storing failed, log the error code */ if ( $result === false ) {

@@ -979,8 +896,8 @@ * @param string $key Key to set with

* @param mixed $data Data to set * */ - private function memcache_set ( &$key, &$data ) { - $result = $this->connection->set ( $key, $data , 0 , $this->options['expire'] ); + private function memcache_set ( &$key, &$data, &$expire ) { + $result = $this->connection->set ( $key, $data , 0 , $expire ); return $result; }
M wp-ffpc-class.phpwp-ffpc-class.php

@@ -180,6 +180,8 @@ /* get all available post types */

$post_types = get_post_types( ); /* cache invalidation hooks */ + add_action( 'transition_post_status', array( &$this->backend , 'clear_ng' ), 10, 3 ); + /* foreach ( $post_types as $post_type ) { add_action( 'new_to_publish_' .$post_type , array( &$this->backend , 'clear' ), 0 ); add_action( 'draft_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 );

@@ -187,6 +189,7 @@ add_action( 'pending_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 );

add_action( 'private_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 ); add_action( 'publish_' . $post_type , array( &$this->backend , 'clear' ), 0 ); } + */ /* comments invalidation hooks */ if ( $this->options['comments_invalidate'] ) {

@@ -462,11 +465,27 @@ <span class="description"><?php _e('Select backend storage driver', $this->plugin_constant); ?></span>

</dd> <dt> - <label for="expire"><?php _e('Expiration time (seconds)', $this->plugin_constant); ?></label> + <label for="expire"><?php _e('Expiration time for posts', $this->plugin_constant); ?></label> </dt> <dd> <input type="number" name="expire" id="expire" value="<?php echo $this->options['expire']; ?>" /> - <span class="description"><?php _e('Sets validity time of entry in seconds', $this->plugin_constant); ?></span> + <span class="description"><?php _e('Sets validity time of post entry in seconds, including custom post types and pages.', $this->plugin_constant); ?></span> + </dd> + + <dt> + <label for="expire_taxonomy"><?php _e('Expiration time for taxonomy', $this->plugin_constant); ?></label> + </dt> + <dd> + <input type="number" name="expire_taxonomy" id="expire_taxonomy" value="<?php echo $this->options['expire_taxonomy']; ?>" /> + <span class="description"><?php _e('Sets validity time of taxonomy entry in seconds, including custom taxonomy.', $this->plugin_constant); ?></span> + </dd> + + <dt> + <label for="expire_home"><?php _e('Expiration time for home', $this->plugin_constant); ?></label> + </dt> + <dd> + <input type="number" name="expire_home" id="expire_home" value="<?php echo $this->options['expire_home']; ?>" /> + <span class="description"><?php _e('Sets validity time of home.', $this->plugin_constant); ?></span> </dd> <dt>
M wp-ffpc.phpwp-ffpc.php

@@ -3,7 +3,7 @@ /*

Plugin Name: WP-FFPC Plugin URI: https://github.com/petermolnar/wp-ffpc Description: WordPress in-memory full page cache plugin -Version: 1.6.4 +Version: 1.7.0 Author: Peter Molnar <hello@petermolnar.eu> Author URI: http://petermolnar.eu/ License: GPLv3

@@ -32,6 +32,8 @@ 'hosts'=>'127.0.0.1:11211',

'authpass'=>'', 'authuser'=>'', 'expire'=>300, + 'expire_home'=>300, + 'expire_taxonomy'=>300, 'invalidation_method'=>0, 'prefix_meta' =>'meta-', 'prefix_data' =>'data-',

@@ -55,6 +57,6 @@ 'key' => '$scheme://$host$request_uri',

'comments_invalidate' => true, ); -$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.6.0', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' ); +$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.7.0', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' ); ?>