diff --git a/readme.txt b/readme.txt index 0ece9ad..b2280e7 100644 --- a/readme.txt +++ b/readme.txt @@ -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 Requires at least: 3.0 Tested up to: 4.2.1 -Stable tag: 1.8.2 +Stable tag: 1.8.3 License: GPLv3 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 ..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 = *2015-04-30* diff --git a/wp-ffpc-backend.php b/wp-ffpc-backend.php index 4aae169..9e34e53 100644 --- a/wp-ffpc-backend.php +++ b/wp-ffpc-backend.php @@ -139,10 +139,11 @@ class WP_FFPC_Backend { $urimap = $customUrimap ?: $this->urimap; $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) - $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__( 'setting key for: %s', $this->plugin_constant ), $key_base ) ); diff --git a/wp-ffpc-class.php b/wp-ffpc-class.php index 0a3b218..57285b0 100644 --- a/wp-ffpc-class.php +++ b/wp-ffpc-class.php @@ -576,7 +576,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
options['hashkey'],true); ?> /> - plugin_constant); ?> + module in nginx if you want nginx to fetch the data directly; for details, please see the nginx example tab.', $this->plugin_constant); ?>
@@ -745,6 +745,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
plugin_constant); ?> +
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 HttpSetMiscModule. Otherwise set_sha1 function is not available in nginx.
nginx_example(); ?>
@@ -1019,11 +1020,20 @@ class WP_FFPC extends WP_FFPC_ABSTRACT { /* read the sample file */ $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 */ - $to_replace = array ( 'DATAPREFIX' , 'SERVERROOT', 'SERVERLOG' ); - $replace_with = array ( $this->options['prefix_data'] . $this->options['key'] , ABSPATH, $_SERVER['SERVER_NAME'] ); + $to_replace = array ( 'DATAPREFIX' , 'KEYFORMAT', 'SERVERROOT', 'SERVERLOG' ); + $replace_with = array ( $this->options['prefix_data'], $this->options['key'] , ABSPATH, $_SERVER['SERVER_NAME'] ); $nginx = str_replace ( $to_replace , $replace_with , $nginx ); + /* set upstream servers from configured servers, best to get from the actual backend */ $servers = $this->backend->get_servers(); $nginx_servers = ''; diff --git a/wp-ffpc-nginx-sample.conf b/wp-ffpc-nginx-sample.conf index ce6a628..000fc06 100644 --- a/wp-ffpc-nginx-sample.conf +++ b/wp-ffpc-nginx-sample.conf @@ -70,10 +70,11 @@ MEMCACHED_SERVERS #fastcgi_param SSL_CLIENT_VERIFY $ssl_client_verify if_not_empty; default_type text/html; - set $memcached_raw_key data-$scheme://$host$request_uri; - # uncomment the following line if you have enabled - # sha1 hash option - # set_sha1 $memcached_key $memcached_raw_key; + + set $memcached_raw_key KEYFORMAT; + + HASHEDORNOT + set $memcached_request 1; if ($request_method = POST ) { diff --git a/wp-ffpc.php b/wp-ffpc.php index 7efb1c2..de11818 100644 --- a/wp-ffpc.php +++ b/wp-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.8.2 +Version: 1.8.3 Author: Peter Molnar Author URI: http://petermolnar.eu/ License: GPLv3