This commit is contained in:
Peter Molnar 2015-05-07 13:33:32 +01:00
parent 42bc1771fa
commit 65325033fa
5 changed files with 29 additions and 12 deletions

View file

@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: cache, page cache, full page cache, nginx, memcached, apc, speed Tags: cache, page cache, full page cache, nginx, memcached, apc, speed
Requires at least: 3.0 Requires at least: 3.0
Tested up to: 4.2.1 Tested up to: 4.2.1
Stable tag: 1.8.2 Stable tag: 1.8.3
License: GPLv3 License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -125,6 +125,11 @@ Version numbering logic:
* every .B version indicates new features. * every .B version indicates new features.
* every ..C indicates bugfixes for A.B version. * every ..C indicates bugfixes for A.B version.
= 1.8.3 =
*2015-05-07*
* small change in key creation: prefix is kept in front of sha1 hashes for debugging purposes
= 1.8.2 = = 1.8.2 =
*2015-04-30* *2015-04-30*

View file

@ -139,10 +139,11 @@ class WP_FFPC_Backend {
$urimap = $customUrimap ?: $this->urimap; $urimap = $customUrimap ?: $this->urimap;
$key_base = self::map_urimap($urimap, $this->options['key']); $key_base = self::map_urimap($urimap, $this->options['key']);
/* data is string only with content, meta is not used in nginx */
$key = $prefix . $key_base;
if ( isset($this->options['hashkey']) && $this->options['hashkey'] == true) if ( isset($this->options['hashkey']) && $this->options['hashkey'] == true)
$key = sha1 ($prefix . $key_base ); $key_base = sha1($key_base);
$key = $prefix . $key_base;
$this->log ( sprintf( __translate__( 'original key configuration: %s', $this->plugin_constant ), $this->options['key'] ) ); $this->log ( sprintf( __translate__( 'original key configuration: %s', $this->plugin_constant ), $this->options['key'] ) );
$this->log ( sprintf( __translate__( 'setting key for: %s', $this->plugin_constant ), $key_base ) ); $this->log ( sprintf( __translate__( 'setting key for: %s', $this->plugin_constant ), $key_base ) );

View file

@ -576,7 +576,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
</dt> </dt>
<dd> <dd>
<input type="checkbox" name="hashkey" id="hashkey" value="1" <?php checked($this->options['hashkey'],true); ?> /> <input type="checkbox" name="hashkey" id="hashkey" value="1" <?php checked($this->options['hashkey'],true); ?> />
<span class="description"><?php _e('Occasionally URL can be too long to be used as key for the backend storage, especially with memcached. Turn on this feature to use SHA1 hash of the URL as key instead. Please be aware that you have to add ( or uncomment ) a line in nginx if you want nginx to fetch the data directly; for details, please see the nginx example tab.', $this->plugin_constant); ?> <span class="description"><?php _e('Occasionally URL can be too long to be used as key for the backend storage, especially with memcached. Turn on this feature to use SHA1 hash of the URL as key instead. Please be aware that you have to add ( or uncomment ) a line and a <strong>module</strong> in nginx if you want nginx to fetch the data directly; for details, please see the nginx example tab.', $this->plugin_constant); ?>
</dd> </dd>
@ -745,6 +745,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
<fieldset id="<?php echo $this->plugin_constant ?>-nginx"> <fieldset id="<?php echo $this->plugin_constant ?>-nginx">
<legend><?php _e('Sample config for nginx to utilize the data entries', $this->plugin_constant); ?></legend> <legend><?php _e('Sample config for nginx to utilize the data entries', $this->plugin_constant); ?></legend>
<div class="update-nag"><strong>In case you are about to use nginx to fetch memcached entries directly and to use SHA1 hash keys, you will need an nginx version compiled with <a href="http://wiki.nginx.org/HttpSetMiscModule">HttpSetMiscModule</a>. Otherwise set_sha1 function is not available in nginx.</strong></div>
<pre><?php echo $this->nginx_example(); ?></pre> <pre><?php echo $this->nginx_example(); ?></pre>
</fieldset> </fieldset>
@ -1019,11 +1020,20 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
/* read the sample file */ /* read the sample file */
$nginx = file_get_contents ( $this->nginx_sample ); $nginx = file_get_contents ( $this->nginx_sample );
if ( isset($this->options['hashkey']) && $this->options['hashkey'] == true )
$mckeys = 'set_sha1 $memcached_sha1_key $memcached_raw_key;
set $memcached_key DATAPREFIX$memcached_sha1_key;';
else
$mckeys = 'set $memcached_key DATAPREFIX$memcached_raw_key;';
$nginx = str_replace ( 'HASHEDORNOT' , $mckeys , $nginx );
/* replace the data prefix with the configured one */ /* replace the data prefix with the configured one */
$to_replace = array ( 'DATAPREFIX' , 'SERVERROOT', 'SERVERLOG' ); $to_replace = array ( 'DATAPREFIX' , 'KEYFORMAT', 'SERVERROOT', 'SERVERLOG' );
$replace_with = array ( $this->options['prefix_data'] . $this->options['key'] , ABSPATH, $_SERVER['SERVER_NAME'] ); $replace_with = array ( $this->options['prefix_data'], $this->options['key'] , ABSPATH, $_SERVER['SERVER_NAME'] );
$nginx = str_replace ( $to_replace , $replace_with , $nginx ); $nginx = str_replace ( $to_replace , $replace_with , $nginx );
/* set upstream servers from configured servers, best to get from the actual backend */ /* set upstream servers from configured servers, best to get from the actual backend */
$servers = $this->backend->get_servers(); $servers = $this->backend->get_servers();
$nginx_servers = ''; $nginx_servers = '';

View file

@ -70,10 +70,11 @@ MEMCACHED_SERVERS
#fastcgi_param SSL_CLIENT_VERIFY $ssl_client_verify if_not_empty; #fastcgi_param SSL_CLIENT_VERIFY $ssl_client_verify if_not_empty;
default_type text/html; default_type text/html;
set $memcached_raw_key data-$scheme://$host$request_uri;
# uncomment the following line if you have enabled set $memcached_raw_key KEYFORMAT;
# sha1 hash option
# set_sha1 $memcached_key $memcached_raw_key; HASHEDORNOT
set $memcached_request 1; set $memcached_request 1;
if ($request_method = POST ) { if ($request_method = POST ) {

View file

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