all repos — wp-ffpc @ 2b2345c763ec6913aa56f2d1b89496f34a662a09

version 1.6.0, see changelog
Peter Molnar hello@petermolnar.eu
Fri, 22 Aug 2014 11:55:25 +0100
commit

2b2345c763ec6913aa56f2d1b89496f34a662a09

parent

aaf703fd8d4a18daabcfbfcd41cf4f4f8fa1be53

5 files changed, 114 insertions(+), 46 deletions(-)

jump to
M readme.txtreadme.txt

@@ -3,8 +3,8 @@ Contributors: cadeyrn

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: 3.9.1 -Stable tag: 1.5.0 +Tested up to: 4.0 +Stable tag: 1.6.0 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html

@@ -17,14 +17,14 @@

= Features: = * Wordpress Network support * fully supported domain/subdomain based WordPress Networks on per site setup as well - * will work in Network Enabled mode only for subdirectory based Multisites ( no per site setting possibility ) -* supports variable backends + * will work in Network Enabled mode only for subdirectory based Multisites ( per site settings will not work in this case ) +* supports various backends * memcached with [PHP Memcached](http://php.net/manual/en/book.memcached.php "Memcached") * memcached with [PHP Memcache](http://php.net/manual/en/book.memcache.php "Memcache") * [APC](http://php.net/manual/en/book.apc.php "APC") * [APCu](http://pecl.php.net/package/APCu "APC User Cache") * [Xcache](http://xcache.lighttpd.net/ "Xcache") - not stable yet, volunteer testers required! -* cache exclude possibilities ( home, feeds, archieves, pages, singles ) +* cache exclude options ( home, feeds, archieves, pages, singles; regex based url exclusion ) * (optional) cache for logged-in users * 404 caching * canonical redirects caching

@@ -43,6 +43,8 @@ * [doconeill](http://wordpress.org/support/profile/doconeill "doconeill")

* [Mark Costlow](mailto:cheeks@swcp.com "Mark Costlow") * [Jason Miller](mailto:jason@redconfetti.com "Jason Miller") * [Dave Clark](https://github.com/dkcwd "Dave Clark") +* Miguel Clara +* [plescheff](https://github.com/plescheff) == Installation ==

@@ -97,6 +99,29 @@ 4. memcached servers settings

5. NGiNX example == Changelog == + +Version numbering logic: + +* every A. indicates BIG changes. +* every .B version indicates new features. +* every ..C indicates bugfixes for A.B version. + += 1.6.0 = +*2014-05-30* + +What's new: + +* added functionality to exclude regex urls, contribution from [plescheff](https://github.com/plescheff/wp-ffpc/commit/3c875ad4fe1e083d3968421dd83b9c179c686649) +* added functionality to include "?" containing URL + +What's fixed: + +* some warning messages removed in case there's not a single backend installed when the plugin is activated + +Under the hood: + +* major changes to the abstract wp-common class for better interoperability between my plugins + = 1.5.0 = *2014-05-30*
M wp-ffpc-acache.phpwp-ffpc-acache.php

@@ -26,7 +26,7 @@ /* request uri */

$wp_ffpc_uri = $_SERVER['REQUEST_URI']; /* no cache for uri with query strings, things usually go bad that way */ -if ( stripos($wp_ffpc_uri, '?') !== false) +if ( isset($wp_ffpc_config['nocache_dyn']) && !empty($wp_ffpc_config['nocache_dyn']) && stripos($wp_ffpc_uri, '?') !== false ) { return false; /* no cache for pages starting with /wp- like WP admin */

@@ -64,6 +64,14 @@ return false;

} } } + } +} + +/* no cache for excluded URL patterns */ +if ( isset($wp_ffpc_config['nocache_url']) && trim($wp_ffpc_config['nocache_url']) ) { + $pattern = sprintf('#%s#', trim($wp_ffpc_config['nocache_url'])); + if ( preg_match($pattern, $wp_ffpc_uri) ) { + return false; } }

@@ -254,7 +262,7 @@ return $buffer;

} } - if ( is_404() ) + if ( is_404() ) $meta['status'] = 404; /* redirect page */
M wp-ffpc-backend.phpwp-ffpc-backend.php

@@ -520,7 +520,7 @@ return false;

} /* verify apcu is working */ - if ( apcu_cache_info("user",true) ) { + if ( apcu_cache_info("user") ) { $this->log ( __translate__('backend OK', $this->plugin_constant ) ); $this->alive = true; }

@@ -603,6 +603,14 @@ 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; }

@@ -716,7 +724,7 @@ /* use binary and not compressed format, good for nginx and still fast */

$this->connection->setOption( Memcached::OPT_COMPRESSION , false ); $this->connection->setOption( Memcached::OPT_BINARY_PROTOCOL , true ); - if ( version_compare( phpversion( 'memcached' ) , '2.0.0', '>=' ) && ini_get( 'memcached.use_sasl' ) == 1 ) { + if ( version_compare( phpversion( 'memcached' ) , '2.0.0', '>=' ) && ini_get( 'memcached.use_sasl' ) == 1 && isset($this->options['authpass']) && !empty($this->options['authpass']) && isset($this->options['authuser']) && !empty($this->options['authuser']) ) { $this->connection->setSaslAuthData ( $this->options['authuser'], $this->options['authpass']); } }
M wp-ffpc-class.phpwp-ffpc-class.php

@@ -3,9 +3,9 @@

if ( ! class_exists( 'WP_FFPC' ) ) : /* get the plugin abstract class*/ -include_once ( 'wp-common/plugin_abstract.php' ); +include_once ( dirname(__FILE__) . '/wp-common/plugin_abstract.php' ); /* get the common functions class*/ -include_once ( 'wp-ffpc-backend.php' ); +include_once ( dirname(__FILE__) .'/wp-ffpc-backend.php' ); /** * main wp-ffpc class

@@ -62,6 +62,20 @@ private $shell_possibilities = array ();

private $backend = NULL; private $scheduled = false; private $errors = array(); + + /** + * + */ + public function plugin_post_construct () { + $this->plugin_url = plugin_dir_url( __FILE__ ); + $this->plugin_dir = plugin_dir_path( __FILE__ ); + + $this->common_url = $this->plugin_url . self::common_slug; + $this->common_dir = $this->plugin_dir . self::common_slug; + + $this->admin_css_handle = $this->plugin_constant . '-admin-css'; + $this->admin_css_url = $this->common_url . 'wp-admin.css'; + } /** * init hook function runs before admin panel hook, themeing and options read

@@ -272,12 +286,11 @@ *

*/ public function plugin_extend_admin_init () { /* save parameter updates, if there are any */ - if ( isset( $_POST[ $this->button_flush ] ) ) { - + if ( isset( $_POST[ $this->button_flush ] ) && check_admin_referer ( $this->plugin_constant ) ) { /* remove precache log entry */ - $this->_delete_option( self::precache_log ); + $this->utils->_delete_option( self::precache_log ); /* remove precache timestamp entry */ - $this->_delete_option( self::precache_timestamp ); + $this->utils->_delete_option( self::precache_timestamp ); /* remove precache logfile */ if ( @file_exists ( $this->precache_logfile ) ) {

@@ -296,8 +309,7 @@ header( "Location: ". $this->settings_link . self::slug_flush );

} /* save parameter updates, if there are any */ - if ( isset( $_POST[ $this->button_precache ] ) ) { - + if ( isset( $_POST[ $this->button_precache ] ) && check_admin_referer ( $this->plugin_constant ) ) { /* is no shell function is possible, fail */ if ( $this->shell_function == false ) { $this->status = 5;

@@ -407,15 +419,17 @@ _e( '<strong>Backend status:</strong><br />', $this->plugin_constant );

/* we need to go through all servers */ $servers = $this->backend->status(); - foreach ( $servers as $server_string => $status ) { - echo $server_string ." => "; + if ( is_array( $servers ) && !empty ( $servers ) ) { + foreach ( $servers as $server_string => $status ) { + echo $server_string ." => "; - if ( $status == 0 ) - _e ( '<span class="error-msg">down</span><br />', $this->plugin_constant ); - elseif ( ( $this->options['cache_type'] == 'memcache' && $status > 0 ) || $status == 1 ) - _e ( '<span class="ok-msg">up & running</span><br />', $this->plugin_constant ); - else - _e ( '<span class="error-msg">unknown, please try re-saving settings!</span><br />', $this->plugin_constant ); + if ( $status == 0 ) + _e ( '<span class="error-msg">down</span><br />', $this->plugin_constant ); + elseif ( ( $this->options['cache_type'] == 'memcache' && $status > 0 ) || $status == 1 ) + _e ( '<span class="ok-msg">up & running</span><br />', $this->plugin_constant ); + else + _e ( '<span class="error-msg">unknown, please try re-saving settings!</span><br />', $this->plugin_constant ); + } } ?></p><?php

@@ -423,6 +437,7 @@ } ?>

</div> <form autocomplete="off" method="post" action="#" id="<?php echo $this->plugin_constant ?>-settings" class="plugin-admin"> + <?php wp_nonce_field( $this->plugin_constant ); ?> <ul class="tabs"> <li><a href="#<?php echo $this->plugin_constant ?>-type" class="wp-switch-editor"><?php _e( 'Cache type', $this->plugin_constant ); ?></a></li> <li><a href="#<?php echo $this->plugin_constant ?>-debug" class="wp-switch-editor"><?php _e( 'Debug & in-depth', $this->plugin_constant ); ?></a></li>

@@ -600,6 +615,26 @@ <dd>

<input type="text" name="nocache_cookies" id="nocache_cookies" value="<?php if(isset( $this->options['nocache_cookies'] ) ) echo $this->options['nocache_cookies']; ?>" /> <span class="description"><?php _e('Exclude cookies names starting with this from caching. Separate multiple cookies names with commas.<br />If you are caching with nginx, you should update your nginx configuration and reload nginx after changing this value.', $this->plugin_constant); ?></span> </dd> + + <dt> + <label for="nocache_dyn"><?php _e("Don't cache dynamic requests", $this->plugin_constant); ?></label> + </dt> + <dd> + <input type="checkbox" name="nocache_dyn" id="nocache_dyn" value="1" <?php checked($this->options['nocache_dyn'],true); ?> /> + <span class="description"><?php _e('Exclude every URL with "?" in it.', $this->plugin_constant); ?></span> + </dd> + + <dt> + <label for="nocache_url"><?php _e("Don't cache following URL paths - use with caution!", $this->plugin_constant); ?></label> + </dt> + <dd> + <textarea name="nocache_url" id="nocache_url" rows="3" cols="100" class="large-text code"><?php + if( isset( $this->options['nocache_url'] ) ) { + echo $this->options['nocache_url']; + } + ?></textarea> + <span class="description"><?php _e('Regular expressions use you must! e.g. <em>pattern1|pattern2|etc</em>', $this->plugin_constant); ?></span> + </dd> </dl> </fieldset>

@@ -717,6 +752,8 @@ </form>

<form method="post" action="#" id="<?php echo $this->plugin_constant ?>-commands" class="plugin-admin" style="padding-top:2em;"> + <?php wp_nonce_field( $this->plugin_constant ); ?> + <ul class="tabs"> <li><a href="#<?php echo $this->plugin_constant ?>-precache" class="wp-switch-editor"><?php _e( 'Precache', $this->plugin_constant ); ?></a></li> <li><a href="#<?php echo $this->plugin_constant ?>-flush" class="wp-switch-editor"><?php _e( 'Empty cache', $this->plugin_constant ); ?></a></li>

@@ -824,9 +861,8 @@ * need to do migrations from previous versions of the plugin

* */ public function plugin_options_migrate( &$options ) { - $migrated = false; - if ( version_compare ( $options['version'] , $this->plugin_version , '<' ) ) { + if ( version_compare ( $options['version'] , $this->plugin_version, '<' ) ) { /* cleanup possible leftover files from previous versions */ $check = array ( 'advanced-cache.php', 'nginx-sample.conf', 'wp-ffpc.admin.css', 'wp-ffpc-common.php' ); foreach ( $check as $fname ) {

@@ -844,37 +880,26 @@ delete_site_option ( $this->plugin_constant );

if ( empty ( $options ) && array_key_exists ( $this->global_config_key, $try ) ) { $options = $try [ $this->global_config_key ]; - $migrated = true; } elseif ( empty ( $options ) && array_key_exists ( 'host', $try ) ) { $options = $try; - $migrated = true; } } /* updating from version <= 0.4.x */ if ( !empty ( $options['host'] ) ) { $options['hosts'] = $options['host'] . ':' . $options['port']; - $migrated = true; } /* migrating from version 0.6.x */ elseif ( is_array ( $options ) && array_key_exists ( $this->global_config_key , $options ) ) { $options = $options[ $this->global_config_key ]; - $migrated = true; - } - /* migrating from something, drop previous config */ - else { - $options = array(); } - if ( $migrated ) { - /* renamed options */ - if ( isset ( $options['syslog'] ) ) - $options['log'] = $options['syslog']; - if ( isset ( $options['debug'] ) ) + /* renamed options */ + if ( isset ( $options['syslog'] ) ) + $options['log'] = $options['syslog']; + if ( isset ( $options['debug'] ) ) $options['response_header'] = $options['debug']; - } - } }

@@ -1146,7 +1171,7 @@ break;

} /* in case the bloglinks are relative links add the base url, site specific */ - $baseurl = empty( $url ) ? $this->_site_url() : $url; + $baseurl = empty( $url ) ? $this->utils->_site_url() : $url; if ( !strstr( $permalink, $baseurl ) ) { $permalink = $baseurl . $permalink; }
M wp-ffpc.phpwp-ffpc.php

@@ -1,9 +1,9 @@

<?php /* Plugin Name: WP-FFPC -Plugin URI: http://petermolnar.eu/wordpress/wp-ffpc -Description: WordPress cache plugin for memcached & nginx - unbeatable speed -Version: 1.5.0 +Plugin URI: https://github.com/petermolnar/wp-ffpc +Description: WordPress in-memory full page cache plugin +Version: 1.6.0 Author: Peter Molnar <hello@petermolnar.eu> Author URI: http://petermolnar.eu/ License: GPLv3

@@ -45,6 +45,8 @@ 'nocache_archive' => false,

'nocache_single' => false, 'nocache_page' => false, 'nocache_cookies' => false, + 'nocache_dyn' => true, + 'nocache_url' => '', 'persistent' => false, 'response_header' => false, 'generate_time' => false,