diff --git a/index-redis-page-cache.php b/index-redis-page-cache.php index 3a57ce256d59ae7e82b47e10bd8c8ed83c1192af..5ab72e08e7e6d1d515dd28efc231281e8fa47b7a 100644 --- a/index-redis-page-cache.php +++ b/index-redis-page-cache.php @@ -42,6 +42,7 @@ $redis_page_cache_config = array( 'cache_headers' => true, 'additional_headers' => array( 'link', 'x-hacker', 'x-pingback' ), 'query_strings_to_ignore' => array(), // common tracking strings are automatically excluded + 'minify' => false, ); // Uncomment either option below to fix the values here and disable the admin UI @@ -408,6 +409,14 @@ try { 'headers' => array(), ); + // Minify cached content + if ( $redis_page_cache_config['minify'] ) { + $search = array( '#\>[^\S ]+#s', '#[^\S ]+\<#s', '#(\s)+#s' ); + $replace = array( '>', '<', '\\1' ); + + $cache['output'] = preg_replace( $search, $replace, $cache['output'] ); + } + // Capture certain headers // Props to @andy and Batcache (http://wordpress.org/plugins/batcache/) for this code if ( ! empty( $redis_page_cache_config['additional_headers' ] ) ) {