= 1.10.1 =

*2015-10-30*

* fixed nginx configuration sample snippets
* nginx configuration moved from Settings tab to Help tab, so if you're looking for the "nginx" tab, you need to look under "Help" on the WP-FFPC Settings page.
This commit is contained in:
Peter Molnar 2015-10-30 15:41:37 +00:00
parent 06bee4b178
commit 62f3d0ab00
4 changed files with 129 additions and 114 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.3.1 Tested up to: 4.3.1
Stable tag: 1.10.0 Stable tag: 1.10.1
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
@ -80,6 +80,7 @@ Many thanks for donations, contributors, supporters, testers & bug reporters:
* Christian Kernbeis * Christian Kernbeis
* Gausden Barry * Gausden Barry
* Maksim Bukreyeu * Maksim Bukreyeu
* Lissome Hong Kong Limited
== Installation == == Installation ==
@ -129,6 +130,12 @@ 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.10.1 =
*2015-10-30*
* fixed nginx configuration sample snippets
* nginx configuration moved from Settings tab to Help tab, so if you're looking for the "nginx" tab, you need to look under "Help" on the WP-FFPC Settings page.
= 1.10.0 = = 1.10.0 =
*2015-10-23* *2015-10-23*

View file

@ -261,6 +261,8 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
} }
} }
} }
add_filter('contextual_help', array( &$this, 'plugin_admin_nginx_help' ), 10, 2);
} }
/** /**
@ -371,6 +373,28 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
return $contextual_help; return $contextual_help;
} }
/**
* admin help panel
*/
public function plugin_admin_nginx_help($contextual_help, $screen_id ) {
/* add our page only if the screenid is correct */
if ( strpos( $screen_id, $this->plugin_settings_page ) ) {
$content = __('<h3>Sample config for nginx to utilize the data entries</h3>', 'wp-ffpc');
$content .= __('<div class="update-nag">This is not meant to be a copy-paste configuration; you most probably have to tailor it to your needs.</div>', 'wp-ffpc');
$content .= __('<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>', 'wp-ffpc');
$content .= '<code><pre>' . $this->nginx_example() . '</pre></code>';
get_current_screen()->add_help_tab( array(
'id' => 'wp-ffpc-nginx-help',
'title' => __( 'nginx example', 'wp-ffpc' ),
'content' => $content,
) );
}
return $contextual_help;
}
/** /**
* admin panel, the admin page displayed for plugin settings * admin panel, the admin page displayed for plugin settings
*/ */
@ -781,12 +805,6 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
</dl> </dl>
</fieldset> </fieldset>
<fieldset id="<?php echo $this->plugin_constant ?>-nginx">
<legend><?php _e('Sample config for nginx to utilize the data entries', 'wp-ffpc'); ?></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>
</fieldset>
<fieldset id="<?php echo $this->plugin_constant ?>-precache"> <fieldset id="<?php echo $this->plugin_constant ?>-precache">
<legend><?php _e('Precache settings & log from previous pre-cache generation', 'wp-ffpc'); ?></legend> <legend><?php _e('Precache settings & log from previous pre-cache generation', 'wp-ffpc'); ?></legend>
@ -909,7 +927,6 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
'debug' => __( 'Debug & in-depth', 'wp-ffpc'), 'debug' => __( 'Debug & in-depth', 'wp-ffpc'),
'exceptions' => __( 'Cache exceptions', 'wp-ffpc'), 'exceptions' => __( 'Cache exceptions', 'wp-ffpc'),
'servers' => __( 'Backend settings', 'wp-ffpc'), 'servers' => __( 'Backend settings', 'wp-ffpc'),
'nginx' => __( 'nginx', 'wp-ffpc'),
'precache' => __( 'Precache & precache log', 'wp-ffpc') 'precache' => __( 'Precache & precache log', 'wp-ffpc')
); );
@ -1060,10 +1077,10 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
$nginx = file_get_contents ( $this->nginx_sample ); $nginx = file_get_contents ( $this->nginx_sample );
if ( isset($this->options['hashkey']) && $this->options['hashkey'] == true ) if ( isset($this->options['hashkey']) && $this->options['hashkey'] == true )
$mckeys = 'set_sha1 $memcached_sha1_key $memcached_raw_key; $mckeys = ' set_sha1 $memcached_sha1_key $memcached_raw_key;
set $memcached_key DATAPREFIX$memcached_sha1_key;'; set $memcached_key DATAPREFIX$memcached_sha1_key;';
else else
$mckeys = 'set $memcached_key DATAPREFIX$memcached_raw_key;'; $mckeys = ' set $memcached_key DATAPREFIX$memcached_raw_key;';
$nginx = str_replace ( 'HASHEDORNOT' , $mckeys , $nginx ); $nginx = str_replace ( 'HASHEDORNOT' , $mckeys , $nginx );
@ -1089,9 +1106,9 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
$loggedincookies = join('|', $this->backend->cookies ); $loggedincookies = join('|', $this->backend->cookies );
/* this part is not used when the cache is turned on for logged in users */ /* this part is not used when the cache is turned on for logged in users */
$loggedin = ' $loggedin = '
if ($http_cookie ~* "'. $loggedincookies .'" ) { if ($http_cookie ~* "'. $loggedincookies .'" ) {
set $memcached_request 0; set $memcached_request 0;
}'; }';
/* add logged in cache, if valid */ /* add logged in cache, if valid */
if ( ! $this->options['cache_loggedin']) if ( ! $this->options['cache_loggedin'])
@ -1104,9 +1121,9 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
$cookies = str_replace( ",","|", $this->options['nocache_cookies'] ); $cookies = str_replace( ",","|", $this->options['nocache_cookies'] );
$cookies = str_replace( " ","", $cookies ); $cookies = str_replace( " ","", $cookies );
$cookie_exception = '# avoid cache for cookies specified $cookie_exception = '# avoid cache for cookies specified
if ($http_cookie ~* ' . $cookies . ' ) { if ($http_cookie ~* ' . $cookies . ' ) {
set $memcached_request 0; set $memcached_request 0;
}'; }';
$nginx = str_replace ( 'COOKIES_EXCEPTION' , $cookie_exception , $nginx ); $nginx = str_replace ( 'COOKIES_EXCEPTION' , $cookie_exception , $nginx );
} else { } else {
$nginx = str_replace ( 'COOKIES_EXCEPTION' , '' , $nginx ); $nginx = str_replace ( 'COOKIES_EXCEPTION' , '' , $nginx );
@ -1121,7 +1138,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
$nginx = str_replace ( 'RESPONSE_HEADER' , '' , $nginx ); $nginx = str_replace ( 'RESPONSE_HEADER' , '' , $nginx );
} }
return $nginx; return htmlspecialchars($nginx);
} }
/** /**

View file

@ -1,116 +1,107 @@
http { # --- contents of {nginx config dir, usuall /etc/nginx}/fastcgi_params ---
fastcgi_param SCRIPT_NAME $script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param SSL_PROTOCOL $ssl_protocol if_not_empty;
fastcgi_param SSL_CIPHER $ssl_cipher if_not_empty;
fastcgi_param SSL_SESSION_ID $ssl_session_id if_not_empty;
fastcgi_param SSL_CLIENT_VERIFY $ssl_client_verify if_not_empty;
fastcgi_param REDIRECT_STATUS 200;
fastcgi_index index.php;
fastcgi_connect_timeout 10;
fastcgi_send_timeout 360;
fastcgi_read_timeout 3600;
fastcgi_buffer_size 512k;
fastcgi_buffers 512 512k;
fastcgi_intercept_errors on;
# memcached servers, generated according to wp-ffpc config
upstream memcached-servers {
# --- part needs to go inside the http { } block of nginx ---
# --- memcached ---
upstream memcached {
MEMCACHED_SERVERS MEMCACHED_SERVERS
} }
# PHP-FPM upstream; change it accordingly to your local config! # --- PHP-FPM upstream --- change it accordingly to your local config!
upstream php-fpm { upstream php-fpm {
server 127.0.0.1:9000; server 127.0.0.1:9000;
} }
server {
## Listen ports
listen 80;
listen [::]:80;
# use _ if you want to accept everything, or replace _ with domain # --- part needs to go inside the server { } block of nginx ---
server_name _; set $memcached_raw_key KEYFORMAT;
# root of WordPress HASHEDORNOT
root SERVERROOT;
# set up logging set $memcached_request 1;
access_log /var/log/nginx/SERVERLOG.access.log;
error_log /var/log/nginx/SERVERLOG.error.log;
## PHP5-FPM if ($request_method = POST ) {
location ~ (\.php) { set $memcached_request 0;
# these settings are usually in fastcgi_params }
fastcgi_index index.php; if ( $uri ~ "/wp-" ) {
fastcgi_connect_timeout 10; set $memcached_request 0;
fastcgi_send_timeout 180; }
fastcgi_read_timeout 180;
fastcgi_buffer_size 512k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 512k;
fastcgi_temp_file_write_size 512k;
fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_keep_conn on;
fastcgi_param QUERY_STRING $query_string; if ( $args ) {
fastcgi_param REQUEST_METHOD $request_method; set $memcached_request 0;
fastcgi_param CONTENT_TYPE $content_type; }
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param REDIRECT_STATUS 200;
# uncomment these for HTTPS usage LOGGEDIN_EXCEPTION
#fastcgi_param HTTPS $https if_not_empty;
#fastcgi_param SSL_PROTOCOL $ssl_protocol if_not_empty;
#fastcgi_param SSL_CIPHER $ssl_cipher if_not_empty;
#fastcgi_param SSL_SESSION_ID $ssl_session_id if_not_empty;
#fastcgi_param SSL_CLIENT_VERIFY $ssl_client_verify if_not_empty;
default_type text/html; COOKIES_EXCEPTION
set $memcached_raw_key KEYFORMAT;
HASHEDORNOT location ~ ^(?<script_name>.+?\.php)(?<path_info>.*)$ {
default_type text/html;
set $memcached_request 1; if ( $memcached_request = 1) {
RESPONSE_HEADER
memcached_pass memcached;
error_page 404 = @fallback;
}
if ($request_method = POST ) { fastcgi_split_path_info ^(?<script_name>.+?\.php)(?<path_info>.*)$;
set $memcached_request 0; fastcgi_param SCRIPT_FILENAME $document_root$script_name;
} fastcgi_param PATH_TRANSLATED $document_root$path_info;
include params/fastcgi;
fastcgi_keep_conn on;
fastcgi_pass php-fpm;
}
if ( $uri ~ "/wp-" ) { location / {
set $memcached_request 0; try_files $uri $uri/ @rewrites;
} }
if ( $args ) { location @fallback {
set $memcached_request 0; # add_header X-Cache-Engine "WP-FFPC nginx via memcached - fallback - not cached";
}
LOGGEDIN_EXCEPTION fastcgi_split_path_info ^(?<script_name>.+?\.php)(?<path_info>.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$script_name;
fastcgi_param PATH_TRANSLATED $document_root$path_info;
include fastcgi_params;
fastcgi_keep_conn on;
fastcgi_pass php-fpm;
}
COOKIES_EXCEPTION location @rewrites {
rewrite ^ /index.php last;
}
if ( $memcached_request = 1) {
RESPONSE_HEADER
memcached_pass memcached-servers;
error_page 404 = @nocache;
break;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location @nocache {
add_header X-Cache-Engine "not cached";
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location / {
try_files $uri $uri/ /index.php;
}
}
}

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.10.0 Version: 1.10.1
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