Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 23244)
+++ wp-includes/functions.php	(working copy)
@@ -924,10 +924,29 @@
  */
 function nocache_headers() {
 	$headers = wp_get_nocache_headers();
+
+	if ( empty( $headers['Last-Modified'] ) ) {
+		// In PHP 5.3+, make sure we are not sending a Last-Modified header.
+		if ( function_exists( 'header_remove' ) ) {
+			@header_remove( 'Last-Modified' );
+			unset( $headers['Last-Modified'] );
+		} else {
+			// In PHP 5.2, send an empty Last-Modified header, but only as a
+			// last resort to override a header already sent. #WP23021
+			$override = false;
+			foreach ( headers_list() as $header ) {
+				if ( 0 === stripos( $header, 'Last-Modified' ) ) {
+					$override = true;
+					break;
+				}
+			}
+			if ( ! $override )
+				unset( $headers['Last-Modified'] );
+		}
+	}
+
 	foreach( $headers as $name => $field_value )
 		@header("{$name}: {$field_value}");
-	if ( empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) )
-		@header_remove( 'Last-Modified' );
 }
 
 /**
