Commit 20469b96 authored by Erick Hitter's avatar Erick Hitter

Output content encoding headers for happy receipients

parent 1ca474a7
...@@ -315,6 +315,9 @@ try { ...@@ -315,6 +315,9 @@ try {
// Retrieve cached page, which is an array that includes meta data along with the page output // 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'] ) ); $cache = unserialize( $redis->get( $redis_page_cache_config['redis_key'] ) );
// Set headers related to content type
header( 'Content-Type: ' . $cache['content_type'] . '; charset=' . $cache['content_encoding'], true );
// Output cached headers from original page // Output cached headers from original page
if ( ! empty( $cache['headers'] ) ) { if ( ! empty( $cache['headers'] ) ) {
foreach ( $cache['headers'] as $key => $value ) { foreach ( $cache['headers'] as $key => $value ) {
...@@ -332,7 +335,7 @@ try { ...@@ -332,7 +335,7 @@ try {
echo trim( $cache['output'] ); echo trim( $cache['output'] );
// Display generation stats if requested // Display generation stats if requested
if ( $redis_page_cache_config['stats'] ) { if ( 'application/xml' !== $cache['content_type'] && $redis_page_cache_config['stats'] ) {
echo "\n<!-- Page cached via Redis using the Redis Page Cache plugin (http://eth.pw/rpc). -->"; 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. -->"; echo "\n<!-- Retrieved from cache in " . redis_page_cache_time_elapsed( $start, microtime() ) . " seconds. -->";
} }
...@@ -364,7 +367,7 @@ try { ...@@ -364,7 +367,7 @@ try {
echo $output; echo $output;
// Display generation stats if requested // Display generation stats if requested
if ( $redis_page_cache_config['stats'] ) { if ( ! is_feed() && $redis_page_cache_config['stats'] ) {
echo "\n<!-- Page NOT cached via Redis using the Redis Page Cache plugin (http://eth.pw/rpc). -->"; echo "\n<!-- Page NOT cached via Redis using the Redis Page Cache plugin (http://eth.pw/rpc). -->";
echo "\n<!-- Generated and cached in " . redis_page_cache_time_elapsed( $start, microtime() ) . " seconds. -->"; echo "\n<!-- Generated and cached in " . redis_page_cache_time_elapsed( $start, microtime() ) . " seconds. -->";
} }
...@@ -373,10 +376,12 @@ try { ...@@ -373,10 +376,12 @@ try {
if ( ! is_404() && ! is_search() ) { if ( ! is_404() && ! is_search() ) {
// Default cache payload // Default cache payload
$cache = array( $cache = array(
'output' => $output, 'output' => $output,
'time' => time(), 'time' => time(),
'age' => 31536000, // one year in seconds 'age' => 31536000, // one year in seconds
'headers' => array(), 'content_type' => is_feed() ? 'application/xml' : 'text/html',
'content_encoding' => get_option( 'blog_charset', 'UTF-8' ),
'headers' => array(),
); );
// Capture certain headers // Capture certain 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