From 63b01d134161789a48fcad72678572d25c3fe0cb Mon Sep 17 00:00:00 2001
From: Erick Hitter <ehitter@gmail.com>
Date: Thu, 27 Feb 2014 18:23:48 -0800
Subject: [PATCH] Better code organization and some inline comments for the
 changes from 19d6f1.

See #3.
---
 index-redis-page-cache.php | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/index-redis-page-cache.php b/index-redis-page-cache.php
index 7b83886..db35c7c 100644
--- a/index-redis-page-cache.php
+++ b/index-redis-page-cache.php
@@ -308,25 +308,28 @@ try {
 		$load_wp = false;
 		$redis_page_cache_config['cached'] = true;
 
+		// Retrieve cached page, which is an array that includes meta data along with the page output
 		$cache = unserialize( $redis->get( $redis_page_cache_config['redis_key'] ) );
 
+		// Output cache headers if desired
 		if ( $redis_page_cache_config['cache_headers'] ) {
 			header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', $cache['time'] ) . ' GMT', true );
 			header( 'Cache-Control: max-age=' . $cache['age'] . ', must-revalidate', false );
 		}
 
+		// Output page content
 		echo trim( $cache['output'] );
 
-		if ( $redis_page_cache_config['debug'] ) {
-			$redis_page_cache_config['debug_messages'] .= "<!-- Last Modified: " . gmdate( 'D, d M Y H:i:s', $cache['time'] ) . " GMT . -->\n";
-			$redis_page_cache_config['debug_messages'] .= "<!-- Max Age: " . $cache['age'] . " -->\n";
-		}
-
 		// Display generation stats if requested
 		if ( $redis_page_cache_config['stats'] ) {
 			echo "\n<!-- Page cached via Redis using the Redis Page Cache plugin (http://eth.pw/rpc). -->";
 			echo "\n<!-- Retrieved from cache in " . redis_page_cache_time_elapsed( $start, microtime() ) . " seconds. -->";
 		}
+
+		if ( $redis_page_cache_config['debug'] ) {
+			$redis_page_cache_config['debug_messages'] .= "<!-- Last Modified: " . gmdate( 'D, d M Y H:i:s', $cache['time'] ) . " GMT . -->\n";
+			$redis_page_cache_config['debug_messages'] .= "<!-- Max Age: " . $cache['age'] . " -->\n";
+		}
 	// If the cache does not exist lets display the user the normal page without cache, and then fetch a new cache page
 	} elseif ( $_SERVER['REMOTE_ADDR'] != $redis_page_cache_config['server_ip'] ) {
 		if ( false === strstr( $redis_page_cache_config['current_url'], 'preview=true' ) ) {
-- 
GitLab