all repos — wp-ffpc @ 62f3d0ab00f7bfa9e39ad59c032c7a1eb8948b8d

= 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.
Peter Molnar hello@petermolnar.eu
Fri, 30 Oct 2015 15:41:37 +0000
commit

62f3d0ab00f7bfa9e39ad59c032c7a1eb8948b8d

parent

06bee4b17803c3cee6166f1f9086dd1cf78b4088

4 files changed, 128 insertions(+), 113 deletions(-)

jump to
M readme.txtreadme.txt

@@ -4,7 +4,7 @@ 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: 4.3.1 -Stable tag: 1.10.0 +Stable tag: 1.10.1 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html

@@ -80,6 +80,7 @@ * Knut Sparhell

* Christian Kernbeis * Gausden Barry * Maksim Bukreyeu +* Lissome Hong Kong Limited == Installation ==

@@ -128,6 +129,12 @@

* every A. indicates BIG changes. * every .B version indicates new features. * 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 = *2015-10-23*
M wp-ffpc-class.phpwp-ffpc-class.php

@@ -261,6 +261,8 @@ static::alert ( $msg, LOG_WARNING, $this->network );

} } } + + add_filter('contextual_help', array( &$this, 'plugin_admin_nginx_help' ), 10, 2); } /**

@@ -366,6 +368,28 @@ </ol>' )

) ); */ + } + + 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;

@@ -781,12 +805,6 @@

</dl> </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"> <legend><?php _e('Precache settings & log from previous pre-cache generation', 'wp-ffpc'); ?></legend>

@@ -909,7 +927,6 @@ 'type' => __( 'Cache type', 'wp-ffpc'),

'debug' => __( 'Debug & in-depth', 'wp-ffpc'), 'exceptions' => __( 'Cache exceptions', 'wp-ffpc'), 'servers' => __( 'Backend settings', 'wp-ffpc'), - 'nginx' => __( 'nginx', 'wp-ffpc'), 'precache' => __( 'Precache & precache log', 'wp-ffpc') );

@@ -1060,10 +1077,10 @@ /* 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;'; + $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;'; + $mckeys = ' set $memcached_key DATAPREFIX$memcached_raw_key;'; $nginx = str_replace ( 'HASHEDORNOT' , $mckeys , $nginx );

@@ -1089,9 +1106,9 @@

$loggedincookies = join('|', $this->backend->cookies ); /* this part is not used when the cache is turned on for logged in users */ $loggedin = ' - if ($http_cookie ~* "'. $loggedincookies .'" ) { - set $memcached_request 0; - }'; + if ($http_cookie ~* "'. $loggedincookies .'" ) { + set $memcached_request 0; + }'; /* add logged in cache, if valid */ if ( ! $this->options['cache_loggedin'])

@@ -1104,9 +1121,9 @@ if( $this->options['nocache_cookies'] ) {

$cookies = str_replace( ",","|", $this->options['nocache_cookies'] ); $cookies = str_replace( " ","", $cookies ); $cookie_exception = '# avoid cache for cookies specified - if ($http_cookie ~* ' . $cookies . ' ) { - set $memcached_request 0; - }'; + if ($http_cookie ~* ' . $cookies . ' ) { + set $memcached_request 0; + }'; $nginx = str_replace ( 'COOKIES_EXCEPTION' , $cookie_exception , $nginx ); } else { $nginx = str_replace ( 'COOKIES_EXCEPTION' , '' , $nginx );

@@ -1121,7 +1138,7 @@ else {

$nginx = str_replace ( 'RESPONSE_HEADER' , '' , $nginx ); } - return $nginx; + return htmlspecialchars($nginx); } /**
M wp-ffpc-nginx-sample.confwp-ffpc-nginx-sample.conf

@@ -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 { -MEMCACHED_SERVERS - } - # PHP-FPM upstream; change it accordingly to your local config! - upstream php-fpm { - server 127.0.0.1:9000; - } - server { - ## Listen ports - listen 80; - listen [::]:80; +# --- part needs to go inside the http { } block of nginx --- + # --- memcached --- + upstream memcached { +MEMCACHED_SERVERS + } - # use _ if you want to accept everything, or replace _ with domain - server_name _; + # --- PHP-FPM upstream --- change it accordingly to your local config! + upstream php-fpm { + server 127.0.0.1:9000; + } - # root of WordPress - root SERVERROOT; - # set up logging - access_log /var/log/nginx/SERVERLOG.access.log; - error_log /var/log/nginx/SERVERLOG.error.log; +# --- part needs to go inside the server { } block of nginx --- + set $memcached_raw_key KEYFORMAT; - ## PHP5-FPM - location ~ (\.php) { - # these settings are usually in fastcgi_params + HASHEDORNOT - fastcgi_index index.php; - fastcgi_connect_timeout 10; - 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; + set $memcached_request 1; - 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_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; + if ($request_method = POST ) { + set $memcached_request 0; + } - # uncomment these for HTTPS usage - #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; + if ( $uri ~ "/wp-" ) { + set $memcached_request 0; + } - default_type text/html; + if ( $args ) { + set $memcached_request 0; + } - set $memcached_raw_key KEYFORMAT; + LOGGEDIN_EXCEPTION - HASHEDORNOT + COOKIES_EXCEPTION - set $memcached_request 1; - if ($request_method = POST ) { - set $memcached_request 0; - } + location ~ ^(?<script_name>.+?\.php)(?<path_info>.*)$ { + default_type text/html; - if ( $uri ~ "/wp-" ) { - set $memcached_request 0; - } + if ( $memcached_request = 1) { + RESPONSE_HEADER + memcached_pass memcached; + error_page 404 = @fallback; + } - if ( $args ) { - set $memcached_request 0; - } - - LOGGEDIN_EXCEPTION - - COOKIES_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 params/fastcgi; + fastcgi_keep_conn on; + fastcgi_pass php-fpm; + } - if ( $memcached_request = 1) { - RESPONSE_HEADER - memcached_pass memcached-servers; - error_page 404 = @nocache; - break; - } + location / { + try_files $uri $uri/ @rewrites; + } - fastcgi_pass unix:/var/run/php5-fpm.sock; - } + location @fallback { + # add_header X-Cache-Engine "WP-FFPC nginx via memcached - fallback - not cached"; - location @nocache { - add_header X-Cache-Engine "not cached"; - fastcgi_pass unix:/var/run/php5-fpm.sock; - } + 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; + } - location / { - try_files $uri $uri/ /index.php; - } + location @rewrites { + rewrite ^ /index.php last; + } - } -}
M wp-ffpc.phpwp-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.10.0 +Version: 1.10.1 Author: Peter Molnar <hello@petermolnar.eu> Author URI: http://petermolnar.eu/ License: GPLv3