From 08dafbce5195bde252f4f9b667c032933ac4d562 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 23 Oct 2012 15:45:44 +0000 Subject: [PATCH] Do not issue a Last-Modified header when issuing no-cache headers to avoid aggressive (webkit) caching. Serve a blank header when header_remove() is not available (PHP < 5.3). props andy. fixes #22258. git-svn-id: https://develop.svn.wordpress.org/trunk@22283 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/class-wp.php | 3 +++ wp-includes/functions.php | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index 2e11ebac64..c47679fbe4 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -381,6 +381,9 @@ class WP { foreach( (array) $headers as $name => $field_value ) @header("{$name}: {$field_value}"); + if ( isset( $headers['Last-Modified'] ) && empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) ) + header_remove( 'Last-Modified' ); + if ( $exit_required ) exit(); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index ade297aa66..4a6e0a3b89 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -902,7 +902,7 @@ function status_header( $header ) { function wp_get_nocache_headers() { $headers = array( 'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', - 'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT', + 'Last-Modified' => '', 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', 'Pragma' => 'no-cache', ); @@ -926,6 +926,8 @@ function nocache_headers() { $headers = wp_get_nocache_headers(); foreach( $headers as $name => $field_value ) @header("{$name}: {$field_value}"); + if ( empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) ) + header_remove( 'Last-Modified' ); } /**