Skip to content
Snippets Groups Projects
Commit a457962c authored by Erick Hitter's avatar Erick Hitter
Browse files

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

parent e66f029e
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ $redis_page_cache_config = array( ...@@ -42,6 +42,7 @@ $redis_page_cache_config = array(
'cache_headers' => true, 'cache_headers' => true,
'additional_headers' => array( 'link', 'x-hacker', 'x-pingback' ), 'additional_headers' => array( 'link', 'x-hacker', 'x-pingback' ),
'query_strings_to_ignore' => array(), // common tracking strings are automatically excluded '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 // Uncomment either option below to fix the values here and disable the admin UI
...@@ -408,6 +409,14 @@ try { ...@@ -408,6 +409,14 @@ try {
'headers' => array(), '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 // Capture certain headers
// Props to @andy and Batcache (http://wordpress.org/plugins/batcache/) for this code // Props to @andy and Batcache (http://wordpress.org/plugins/batcache/) for this code
if ( ! empty( $redis_page_cache_config['additional_headers' ] ) ) { if ( ! empty( $redis_page_cache_config['additional_headers' ] ) ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment