Compare commits

...

6 commits

Author SHA1 Message Date
Peter Molnar
b894610cb1 typos 2017-02-11 00:11:35 +00:00
Peter Molnar
eac45ed95e Merge branch 'master' of github:/petermolnar/wp-ffpc
Conflicts:
	wp-ffpc-class.php
2017-02-10 21:34:54 +00:00
Peter Molnar
705afd1535 cleanup for development hibernation 2017-02-10 21:32:34 +00:00
Peter Molnar
b19e446e0f Merge pull request #50 from gablau/master
Some fix
2016-09-27 09:10:06 +01:00
Gabriele Lauricella
24430be27a some fix
* woocommerce api endpoint
* small fix
2016-04-22 17:27:57 +02:00
Gabriele Lauricella
4b5bce6cc4 Merge pull request #1 from petermolnar/master
sync
2016-04-22 17:20:23 +02:00
5 changed files with 114 additions and 277 deletions

View file

@ -1,156 +0,0 @@
<?php
if (!class_exists('WP_FFPC_Backend_redis')):
class WP_FFPC_Backend_redis extends WP_FFPC_Backend {
protected function _init () {
/* Memcached class does not exist, Memcached extension is not available */
if (!class_exists('Redis')) {
$this->log ( __translate__('Redis extension missing, wp-ffpc will not be able to function correctly!', $this->plugin_constant ), LOG_WARNING );
return false;
}
/* check for existing server list, otherwise we cannot add backends */
if ( empty ( $this->options['servers'] ) && ! $this->alive ) {
$this->log ( __translate__("Redis servers list is empty, init failed", $this->plugin_constant ), LOG_WARNING );
return false;
}
/* check is there's no backend connection yet */
if ( $this->connection === NULL ) {
$this->connection = new Redis();
}
/* check if initialization was success or not */
if ( $this->connection === NULL ) {
$this->log ( __translate__( 'error initializing Redis PHP extension, exiting', $this->plugin_constant ) );
return false;
}
/* check if we already have list of servers, only add server(s) if it's not already connected *
$servers_alive = array();
if ( !empty ( $this->status ) ) {
$servers_alive = $this->connection->getServerList();
/* create check array if backend servers are already connected *
if ( !empty ( $servers ) ) {
foreach ( $servers_alive as $skey => $server ) {
$skey = $server['host'] . ":" . $server['port'];
$servers_alive[ $skey ] = true;
}
}
}
/* adding servers */
foreach ( $this->options['servers'] as $server_id => $server ) {
/* only add servers that does not exists already in connection pool */
if ( !@array_key_exists($server_id , $servers_alive ) ) {
if ( $server['port'] != 0)
$this->connection->connect($server['host'], $server['port'] );
else
$this->connection->connect($server['host'] );
if ( isset($this->options['authpass']) && !empty($this->options['authpass']) )
$this->connection->auth ( $this->options['authpass'] );
$this->log ( sprintf( __translate__( '%s added', $this->plugin_constant ), $server_id ) );
}
}
/* backend is now alive */
$this->alive = true;
$this->_status();
}
/**
* sets current backend alive status for Memcached servers
*
*/
protected function _status () {
/* server status will be calculated by getting server stats */
$this->log ( __translate__("checking server status", $this->plugin_constant ));
try {
$info = $this->connection->ping();
} catch ( Exception $e ) {
$this->log ( __translate__("Exception occured: " . json_encode($e), $this->plugin_constant ));
}
$status = empty( $info ) ? 0 : 1;
foreach ( $this->options['servers'] as $server_id => $server ) {
/* reset server status to offline */
$this->status[$server_id] = $status;
}
}
/**
* get function for Memcached backend
*
* @param string $key Key to get values for
*
*/
protected function _get ( &$key ) {
return $this->connection->get($key);
}
/**
* Set function for Memcached backend
*
* @param string $key Key to set with
* @param mixed $data Data to set
*
*/
protected function _set ( &$key, &$data, &$expire ) {
$result = $this->connection->set ( $key, $data, $expire );
/* if storing failed, log the error code */
//if ( $result === false ) {
$this->log ( sprintf( __translate__( 'set entry returned: %s', $this->plugin_constant ), $result ) );
//}
return $result;
}
/**
*
* Flush memcached entries
*/
protected function _flush ( ) {
try {
$r = $this->connection->flushDB();
} catch ( Exception $e ) {
$this->log ( sprintf( __translate__( 'unable to flush, error: %s', $this->plugin_constant ), json_encode($r) ) );
}
return $r;
}
/**
* Removes entry from Memcached or flushes Memcached storage
*
* @param mixed $keys String / array of string of keys to delete entries with
*/
protected function _clear ( &$keys ) {
/* make an array if only one string is present, easier processing */
if ( !is_array ( $keys ) )
$keys = array ( $keys => true );
try {
$kresult = $this->connection->delete( $keys );
} catch ( Exception $e ) {
$this->log ( sprintf( __translate__( 'unable to delete entry(s): %s', $this->plugin_constant ), json_encode($key) ) );
$this->log ( sprintf( __translate__( 'Redis error: %s', $this->plugin_constant ), json_encode($e) ) );
}
finally {
$this->log ( sprintf( __translate__( 'entry(s) deleted: %s', $this->plugin_constant ), json_encode($keys) ) );
}
}
}
endif;

View file

@ -1,91 +1,72 @@
=== WP-FFPC ===
Contributors: cadeyrn, ameir, haroldkyle, plescheff, dkcwd, IgorCode
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
Contributors: cadeyrn
Tags: cache, nginx, memcached, apc
Requires at least: 3.0
Tested up to: 4.5
Tested up to: 4.7.2
Stable tag: 1.11.2
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
The fastest way to cache: use the memory!
A fast, memory based full page cache plugin supporting APC or memcached.
== Description ==
WP-FFPC ( WordPress Fast Full Page Cache ) is a cache plugin for [WordPress](http://wordpress.org/ "WordPress"). It works with any webserver, including apache2, lighttpd, nginx.
**WARNING** The development of WP-FFPC had been put on hold.
If you need new features, please send code and pull requests to [WP FFPC @ Github](https://github.com/petermolnar/wp-ffpc).
It can be configured to join forces with [NGiNX](http://NGiNX.org "NGiNX")'s built-in [memcached plugin](http://nginx.org/en/docs/http/ngx_http_memcached_module.html "memcached plugin").
*A short why: I developed this plugin in 2010 to support my own site. Right now, as it is, it's working on a few sites I still maintain for friends and since I don't need any additional features, I'm not planning to extend it with things I have no real use of. During the past years I've received some heartwarming donations - unfortunately the amount never came close to consider the project financially beneficial. I removed the donation links and put it on hold for now.*
= **IMPORTANT NOTES, PLEASE READ THIS LIST** =
* Requirements:
* WordPress >= 3.0
* **at least one** of the following for storage backend:
WP-FFPC is a cache plugin for [WordPress](http://wordpress.org/ "WordPress").
It works with any webserver, including, but not limited to, apache2, lighttpd, nginx.
It can be configured together with [NGiNX](http://NGiNX.org "NGiNX") but use [memcached plugin](http://nginx.org/en/docs/http/ngx_http_memcached_module.html "memcached plugin") directly from the webserver, bypassing PHP.
= Requirements =
**This plugin does not kick in right after activation**. You have to adjust the setting in Settings -> WP-FFPC and save the settings.*
* WordPress >= 3.0
* **at least one** of the following for storage backend:
* memcached with [PHP Memcached](http://php.net/manual/en/book.memcached.php "Memcached") > 0.1.0
* memcached with [PHP Memcache](http://php.net/manual/en/book.memcache.php "Memcache") > 2.1.0
* [APC](http://php.net/manual/en/book.apc.php "APC")
* [APCu](http://pecl.php.net/package/APCu "APC User Cache")
* PHP 5.3+ is really highly recommended, see "Known issues"
* This plugin does **not** kick in right after activation. You have to adjust the setting in Settings -> WP-FFPC and save the settings.*
* PHP 5.3+ is really highly recommended, see "Known issues"
= Known issues =
* errors will not be displayed on the admin section if PHP < 5.3, only in the logs. This is due to the limitations of displaying the errors ( admin_notices is a hook, not a filter ) and due to the lack of proper anonymus functions in older PHP. PHP 5.3 is 5 years old, so it's time to upgrade.
* APC with PHP 5.4 is buggy; the plugin with that setup can even make your site slower. Please use APCu or memcached if you're using PHP >= 5.4
* errors will not be displayed on the admin section if PHP < 5.3, only in the logs. This is due to the limitations of displaying the errors ( admin_notices is a hook, not a filter ) and due to the lack of proper anonymus functions in older PHP.
* **If you're using PHP 5.4+ avoid the APC backend: the plugin with that setup can even make your site slower.** Please use APCu or memcached in this case.
= 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 ( per site settings will not work in this case )
* supports various backends
* 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 options ( home, feeds, archieves, pages, singles; regex based url exclusion )
* cache exclude options ( home, feeds, archives, pages, singles; regex based url exclusion )
* minor Woocommerce support
* (optional) cache for logged-in users
* 404 caching
* canonical redirects caching
* Last Modified HTTP header support ( for 304 responses )
* Last Modified HTTP header support (for 304 responses)
* shortlink HTTP header preservation
* 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
* (**warning**: untested since WordPress 3.8) 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 ( per site settings will not work in this case )
Many thanks for donations, contributors, supporters, testers & bug reporters:
* [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)
* Miguel Clara
* [Anton Pelešev](https://github.com/plescheff)
* Firas Dib
* [CotswoldPhoto](http://wordpress.org/support/profile/cotswoldphoto)
* [tamagokun](https://github.com/tamagokun)
* Many Ayromlou
* mailgarant.nl
* Christian Rößner
* [Ameir Abdeldayem](https://github.com/ameir)
* [Alvaro Gonzalez](https://github.com/andor-pierdelacabeza)
* Meint Post
* Knut Sparhell
* Christian Kernbeis
* Gausden Barry
* Maksim Bukreyeu
* Lissome Hong Kong Limited
* [Gabriele Lauricella](https://github.com/gablau)
* 7th Veil, LLC
* Julia Harsch
* Grant Berntsen
Harold Kyle, Eric Gilette, doconeill, Mark Costlow, Jason Miller, Dave Clark, Miguel Clara, Anton Pelešev, Firas Dib, CotswoldPhoto, tamagokun, Many Ayromlou, mailgarant.nl, Christian Rößner, Ameir Abdeldayem, Alvaro Gonzalez, Meint Post, Knut Sparhell, Christian Kernbeis, Gausden Barry, Maksim Bukreyeu, Lissome Hong Kong Limited, Gabriele Lauricella, 7th Veil, LLC, Julia Harsch, Grant Berntsen, Jorgen Ilstad, Cinema Minima for Movie Makers Worldwide
== Installation ==
@ -102,22 +83,27 @@ A short configuration example is generated on the plugin settings page, under `N
== Frequently Asked Questions ==
= How to use the plugin on Amazon Linux? =
You have to remove the default yum package, named `php-pecl-memcache` and install `Memcached` through PECL.
= The plugin is not working! =
= How to use the plugin in a WordPress Network =
From version 1.0, the plugin supports subdomain based WordPress Network with possible different per site cache settings. If the plugin is network active, obviously the network wide settings will be used for all of the sites. If it's activated only on some of the sites, the other will not be affected and even the cache storage backend can be different from site to site.
Did you save the settings as mentioned in this document?
Do you have at lest one supported backend?
= How logging works in the plugin? =
Log levels by default ( if logging enabled ) includes warning and error level standard PHP messages.
Additional info level log is available when [WP_DEBUG](http://codex.wordpress.org/WP_DEBUG "WP_DEBUG") is enabled.
= It's making my site slower than it was! =
= How can I contribute? =
In order to make contributions a lot easier, I've moved the plugin development to [GitHub](https://github.com/petermolnar/wp-ffpc "GitHub"), feel free to fork and put shiny, new things in it and get in touch with me [hello@petermolnar.eu](mailto:hello@petermolnar.eu "hello@petermolnar.eu") when you have it ready.
So far this only happened if PHP 5.4 or higher was used with APC.
Please avoid this setup; PHP 5.4 shipped opcache and APC is full of bugs since then. Use APCu with PHP 5.4+.
= Does it support mobile theme switching? =
No, it doesn't, and with the way it's currently working, it never will.
WP-FFPC is using the URL as key for caching, so it can't differentiate if there is no change in the URL.
*(I personally also disagree with separation of mobile and non-mobile theme; you need to support a plethora of screen sizes and resolutions, so just use responsive designs instead of splitted logics.)*
= Can you please add '(insert shiny new feature here)'? =
Sure. Send me a code and a pull request on [WP FFPC @ Github](https://github.com/petermolnar/wp-ffpc).
Unfortunately I don't have the resources to code it myself, but there are plenty of WordPress developers who would probably do it for a minor fee.
= Where can I turn for support? =
I provide support for the plugin as best as I can, but it comes without guarantee.
Please post feature requests to [WP-FFPC feature request topic](http://wordpress.org/support/topic/feature-requests-14 "WP-FFPC feature request topic") and any questions on the forum.
== Screenshots ==
@ -135,12 +121,21 @@ Version numbering logic:
* every .B version indicates new features.
* every ..C indicates bugfixes for A.B version.
= 1.11.2 =
*2017-02-08*
* annoying typos in text
= 1.11.1 =
*2016-04-21*
*2017-02-08*
* exclude cache for WooCommerce
* fix load textdomain
* add Italian (it_IT) translation
* nonexistent redis support removed (it never got to a usable stable state, mostly due to the chaos with the redis php modules)
* readme cleaned up for development hibernation
* donation link removed
* WP version compatibility bumped
= 1.11.0 =
*2016-01-15*
@ -592,4 +587,4 @@ There are major problems with the "memcache" driver, the source is yet unkown. T
= 0.1 =
*2012-02-16*
* first public release
* first public release

View file

@ -8,7 +8,7 @@ defined('ABSPATH') or die("Walk away.");
function __wp_ffpc_debug__ ( $text ) {
if ( defined('WP_FFPC__DEBUG_MODE') && WP_FFPC__DEBUG_MODE == true)
error_log ( __FILE__ . ': ' . $text );
error_log ( 'WP_FFPC_ACache' . ': ' . $text );
}
/* check for WP cache enabled*/
@ -155,7 +155,7 @@ foreach ( $wp_ffpc_keys as $internal => $key ) {
$value = $wp_ffpc_backend->get ( $key );
if ( ! $value ) {
__wp_ffpc_debug__("No cached data foundd");
__wp_ffpc_debug__("No cached data found");
/* does not matter which is missing, we need both, if one fails, no caching */
wp_ffpc_start();
return;

View file

@ -135,7 +135,6 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
'apcu' => __( 'APCu' , 'wp-ffpc'),
'memcache' => __( 'PHP Memcache' , 'wp-ffpc'),
'memcached' => __( 'PHP Memcached' , 'wp-ffpc'),
'redis' => __( 'Redis (experimental, it will break!)' , 'wp-ffpc'),
);
/* check for required functions / classes for the cache types */
@ -144,7 +143,6 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
'apcu' => function_exists( 'apcu_cache_info' ) ? true : false,
'memcache' => class_exists ( 'Memcache') ? true : false,
'memcached' => class_exists ( 'Memcached') ? true : false,
'redis' => class_exists( 'Redis' ) ? true : false,
);
/* invalidation method possible values array */
@ -408,18 +406,18 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
if( ! function_exists( 'current_user_can' ) || ! current_user_can( 'manage_options' ) ){
die( );
}
/* woo_commenrce page url */
if ( class_exists( 'WooCommerce' ) ) {
$page_wc_checkout=str_replace( home_url(), '', wc_get_page_permalink( 'checkout' ) );
$page_wc_myaccount=str_replace( home_url(), '', wc_get_page_permalink( 'myaccount' ) );
$page_wc_cart=str_replace( home_url(), '', wc_get_page_permalink( 'cart' ) );
$this->options['nocache_woocommerce_url'] = '^'.$page_wc_checkout.'|^'.$page_wc_myaccount.'|^'.$page_wc_cart;
$wcapi='^/wc-api|^/\?wc-api=';
$this->options['nocache_woocommerce_url'] = '^'.$page_wc_checkout.'|^'.$page_wc_myaccount.'|^'.$page_wc_cart.'|'.$wcapi;
} else {
$this->options['nocache_woocommerce_url'] = '';
}
?>
<div class="wrap">
@ -790,7 +788,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
<?php _e('List of backends, with the following syntax: <br />- in case of TCP based connections, list the servers as host1:port1,host2:port2,... . Do not add trailing , and always separate host and port with : .<br />- for a unix socket enter: unix://[socket_path]', 'wp-ffpc'); ?></span>
</dd>
<h3><?php _e('Authentication ( only for SASL enabled Memcached or Redis)')?></h3>
<h3><?php _e('Authentication ( only for SASL enabled Memcached)')?></h3>
<?php
if ( ! ini_get('memcached.use_sasl') && ( !empty( $this->options['authuser'] ) || !empty( $this->options['authpass'] ) ) ) { ?>
<div class="error"><p><strong><?php _e( 'WARNING: you\'ve entered username and/or password for memcached authentication ( or your browser\'s autocomplete did ) which will not work unless you enable memcached sasl in the PHP settings: add `memcached.use_sasl=1` to php.ini' , 'wp-ffpc') ?></strong></p></div>

View file

@ -3,70 +3,70 @@
Plugin Name: WP-FFPC
Plugin URI: https://github.com/petermolnar/wp-ffpc
Description: WordPress in-memory full page cache plugin
Version: 1.11.1
Version: 1.11.2
Author: Peter Molnar <hello@petermolnar.eu>
Author URI: http://petermolnar.eu/
Author URI: http://petermolnar.net/
License: GPLv3
Text Domain: wp-ffpc
Domain Path: /languages/
*/
/* Copyright 2010-2014 Peter Molnar ( hello@petermolnar.eu )
/*Copyright 2010-2017 Peter Molnar ( hello@petermolnar.eu )
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 3, as
published by the Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 3, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA02110-1301USA
*/
defined('ABSPATH') or die("Walk away.");
include_once ( 'wp-ffpc-class.php' );
$wp_ffpc_defaults = array (
'hosts'=>'127.0.0.1:11211',
'memcached_binary' => false,
'authpass' => '',
'authuser' => '',
'browsercache' => 0,
'browsercache_home' => 0,
'browsercache_taxonomy' => 0,
'expire' => 300,
'expire_home' => 300,
'expire_taxonomy' => 300,
'invalidation_method' => 0,
'prefix_meta' => 'meta-',
'prefix_data' => 'data-',
'charset' => 'utf-8',
'log' => true,
'cache_type' => 'memcached',
'cache_loggedin' => false,
'nocache_home' => false,
'nocache_feed' => false,
'nocache_archive' => false,
'nocache_single' => false,
'nocache_page' => false,
'nocache_cookies' => false,
'nocache_dyn' => true,
'nocache_woocommerce' => true,
'nocache_woocommerce_url' => '',
'nocache_url' => '^/wp-',
'nocache_comment' => '',
'response_header' => false,
'generate_time' => false,
'precache_schedule' => 'null',
'key' => '$scheme://$host$request_uri',
'comments_invalidate' => true,
'pingback_header' => false,
'hashkey' => false,
$wp_ffpc_defaults= array (
'hosts' => '127.0.0.1:11211',
'memcached_binary' => false,
'authpass' => '',
'authuser' => '',
'browsercache' => 0,
'browsercache_home' => 0,
'browsercache_taxonomy' => 0,
'expire' => 300,
'expire_home' => 300,
'expire_taxonomy' => 300,
'invalidation_method' => 0,
'prefix_meta' => 'meta-',
'prefix_data' => 'data-',
'charset' => 'utf-8',
'log' => true,
'cache_type' => 'memcached',
'cache_loggedin' => false,
'nocache_home' => false,
'nocache_feed' => false,
'nocache_archive' => false,
'nocache_single' => false,
'nocache_page' => false,
'nocache_cookies' => false,
'nocache_dyn' => true,
'nocache_woocommerce' => true,
'nocache_woocommerce_url' => '',
'nocache_url' => '^/wp-',
'nocache_comment' => '',
'response_header' => false,
'generate_time' => false,
'precache_schedule' => 'null',
'key' => '$scheme://$host$request_uri',
'comments_invalidate' => true,
'pingback_header' => false,
'hashkey' => false,
);
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.11.2', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' );
$wp_ffpc= new WP_FFPC ( 'wp-ffpc', '1.11.2', 'WP-FFPC', $wp_ffpc_defaults );