Make WordPress Core

Changeset 23281


Ignore:
Timestamp:
01/04/2013 10:52:10 PM (12 years ago)
Author:
ryan
Message:

Try not to send Last-Modified, even with an empty value. Some servers interpret an empty value as the epoch.

Props nacin, slene, SergeyBiryukov, andy
fixes #23021 for 3.5

Location:
branches/3.5
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.5

  • branches/3.5/wp-admin/includes/update-core.php

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/3.5/wp-includes/class-wp.php

    r22303 r23281  
    379379        if ( ! empty( $status ) )
    380380            status_header( $status );
     381
     382        // If Last-Modified is set to false, it should not be sent (no-cache situation).
     383        if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) {
     384            unset( $headers['Last-Modified'] );
     385
     386            // In PHP 5.3+, make sure we are not sending a Last-Modified header.
     387            if ( function_exists( 'header_remove' ) ) {
     388                @header_remove( 'Last-Modified' );
     389            } else {
     390                // In PHP 5.2, send an empty Last-Modified header, but only as a
     391                // last resort to override a header already sent. #WP23021
     392                foreach ( headers_list() as $header ) {
     393                    if ( 0 === stripos( $header, 'Last-Modified' ) ) {
     394                        $headers['Last-Modified'] = '';
     395                        break;
     396                    }
     397                }
     398            }
     399        }
     400
    381401        foreach( (array) $headers as $name => $field_value )
    382402            @header("{$name}: {$field_value}");
    383 
    384         if ( isset( $headers['Last-Modified'] ) && empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) )
    385             @header_remove( 'Last-Modified' );
    386403
    387404        if ( $exit_required )
  • branches/3.5/wp-includes/functions.php

    r23002 r23281  
    903903    $headers = array(
    904904        'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',
    905         'Last-Modified' => '',
    906905        'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
    907906        'Pragma' => 'no-cache',
     
    911910        $headers = (array) apply_filters('nocache_headers', $headers);
    912911    }
     912    $headers['Last-Modified'] = false;
    913913    return $headers;
    914914}
     
    925925function nocache_headers() {
    926926    $headers = wp_get_nocache_headers();
     927
     928    unset( $headers['Last-Modified'] );
     929
     930    // In PHP 5.3+, make sure we are not sending a Last-Modified header.
     931    if ( function_exists( 'header_remove' ) ) {
     932        @header_remove( 'Last-Modified' );
     933    } else {
     934        // In PHP 5.2, send an empty Last-Modified header, but only as a
     935        // last resort to override a header already sent. #WP23021
     936        foreach ( headers_list() as $header ) {
     937            if ( 0 === stripos( $header, 'Last-Modified' ) ) {
     938                $headers['Last-Modified'] = '';
     939                break;
     940            }
     941        }
     942    }
     943
    927944    foreach( $headers as $name => $field_value )
    928945        @header("{$name}: {$field_value}");
    929     if ( empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) )
    930         @header_remove( 'Last-Modified' );
    931946}
    932947
Note: See TracChangeset for help on using the changeset viewer.