Commit a457962c authored by Erick Hitter's avatar Erick Hitter

Add minification using regex from http://jesin.tk/how-to-use-php-to-minify-html-output/

parent e66f029e
......@@ -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' ] ) ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment