adding new type of HTML debug comment
Peter Molnar hello@petermolnar.eu
Thu, 07 May 2015 14:22:33 +0100
3 files changed,
24 insertions(+),
14 deletions(-)
M
readme.txt
→
readme.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.2.1 -Stable tag: 1.8.3 +Stable tag: 1.8.4 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html@@ -124,6 +124,11 @@
* every A. indicates BIG changes. * every .B version indicates new features. * every ..C indicates bugfixes for A.B version. + += 1.8.4 = +*2015-* + +* changes in HTML debug comment: instead of the former, single comment, now 2 comments are added. The first is added when the cache entry is generated; the second only appears if the page was served from the cached entry. Please note that this last bit will - should - change with every single refresh. = 1.8.3 = *2015-05-07*
M
wp-ffpc-acache.php
→
wp-ffpc-acache.php
@@ -71,14 +71,6 @@ return false;
} } - -/* canonical redirect storage */ -$wp_ffpc_redirect = null; -/* fires up the backend storage array with current config */ -include_once ('wp-ffpc-backend.php'); -$wp_ffpc_backend = new WP_FFPC_Backend( $wp_ffpc_config ); - - /* no cache for for logged in users unless it's set identifier cookies are listed in backend as var for easier usage */@@ -94,6 +86,11 @@ }
} +/* canonical redirect storage */ +$wp_ffpc_redirect = null; +/* fires up the backend storage array with current config */ +include_once ('wp-ffpc-backend.php'); +$wp_ffpc_backend = new WP_FFPC_Backend( $wp_ffpc_config ); /* will store time of page generation */ $wp_ffpc_gentime = 0;@@ -180,6 +177,17 @@ if ( $wp_ffpc_config['response_header'] )
header( 'X-Cache-Engine: WP-FFPC with ' . $wp_ffpc_config['cache_type'] .' via PHP'); /* HTML data */ + +if ( $wp_ffpc_config['generate_time'] == '1' && stripos($wp_ffpc_values['data'], '</body>') ) { + $mtime = explode ( " ", microtime() ); + $wp_ffpc_gentime = ( $mtime[1] + $mtime[0] ) - $wp_ffpc_gentime; + + $insertion = "\n<!-- \nWP-FFPC cache output stats\n\tcache engine: ". $wp_ffpc_config['cache_type'] ."\n\tUNIX timestamp: ". time() . "\n\tdate: ". date( 'c' ) . "\n\tfrom server: ". $_SERVER['SERVER_ADDR'] . "\n\t - if you see this, WP-FFPC used the cache to serve the page\n-->\n"; + $index = stripos( $wp_ffpc_values['data'] , '</body>' ); + + $wp_ffpc_values['data'] = substr_replace( $wp_ffpc_values['data'], $insertion, $index, 0); +} + echo trim($wp_ffpc_values['data']); flush();@@ -308,7 +316,7 @@ global $wp_ffpc_gentime;
$mtime = explode ( " ", microtime() ); $wp_ffpc_gentime = ( $mtime[1] + $mtime[0] )- $wp_ffpc_gentime; - $insertion = "\n<!-- \nWP-FFPC \n\tcache engine: ". $wp_ffpc_config['cache_type'] ."\n\tpage generation time: ". round( $wp_ffpc_gentime, 3 ) ." seconds\n\tgeneraton UNIX timestamp: ". time() . "\n\tgeneraton date: ". date( 'c' ) . "\n\tserver: ". $_SERVER['SERVER_ADDR'] . "\n-->\n"; + $insertion = "\n<!-- \nWP-FFPC cache generation stats" . "\n\tgeneration time: ". round( $wp_ffpc_gentime, 3 ) ." seconds\n\tgeneraton UNIX timestamp: ". time() . "\n\tgeneraton date: ". date( 'c' ) . "\n\tgenerator server: ". $_SERVER['SERVER_ADDR'] . "\n\t - at this point the cache entry is only created by WP-FFPC but the page is not yet served from the cache\n-->\n"; $index = stripos( $buffer , '</body>' ); $buffer = substr_replace( $buffer, $insertion, $index, 0);@@ -318,9 +326,6 @@ $prefix_meta = $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_meta'] );
$wp_ffpc_backend->set ( $prefix_meta, $meta ); $prefix_data = $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_data'] ); - - //if ( $wp_ffpc_config['gzip'] && function_exists('gzencode') ) - $wp_ffpc_backend->set ( $prefix_data , $buffer ); if ( !empty( $meta['status'] ) && $meta['status'] == 404 ) {
M
wp-ffpc.php
→
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.3 +Version: 1.8.4 Author: Peter Molnar <hello@petermolnar.eu> Author URI: http://petermolnar.eu/ License: GPLv3