Make WordPress Core

Ticket #22258: 22258.2.diff

File 22258.2.diff, 2.0 KB (added by andy, 12 years ago)

Empty Last-Modified and remove header if PHP >= 5.3

  • wp-includes/functions.php

     
    902902function wp_get_nocache_headers() {
    903903        $headers = array(
    904904                'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',
    905                 'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT',
     905                'Last-Modified' => '',
    906906                'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
    907907                'Pragma' => 'no-cache',
    908908        );
     
    926926        $headers = wp_get_nocache_headers();
    927927        foreach( $headers as $name => $field_value )
    928928                @header("{$name}: {$field_value}");
     929        if ( function_exists('header_remove') )
     930                header_remove( 'Last-Modified' );
    929931}
    930932
    931933/**
  • wp-includes/class-wp.php

     
    320320                $headers = array('X-Pingback' => get_bloginfo('pingback_url'));
    321321                $status = null;
    322322                $exit_required = false;
     323                $nocache_headers = false;
    323324
    324                 if ( is_user_logged_in() )
     325                if ( is_user_logged_in() ) {
    325326                        $headers = array_merge($headers, wp_get_nocache_headers());
     327                        $nocache_headers = true;
     328                }
     329
    326330                if ( ! empty( $this->query_vars['error'] ) ) {
    327331                        $status = (int) $this->query_vars['error'];
    328332                        if ( 404 === $status ) {
    329                                 if ( ! is_user_logged_in() )
     333                                if ( ! is_user_logged_in() ) {
    330334                                        $headers = array_merge($headers, wp_get_nocache_headers());
     335                                        $nocache_headers = true;
     336                                }
    331337                                $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
    332338                        } elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) {
    333339                                $exit_required = true;
     
    381387                foreach( (array) $headers as $name => $field_value )
    382388                        @header("{$name}: {$field_value}");
    383389
     390                if ( $nocache_headers && function_exists('header_remove') )
     391                        header_remove('Last-Modified');
     392
    384393                if ( $exit_required )
    385394                        exit();
    386395