Make WordPress Core


Ignore:
Timestamp:
05/19/2017 08:26:48 PM (9 years ago)
Author:
jnylen0
Message:

REST API: Avoid sending blank Last-Modified headers with authenticated requests.

This commit adds a new WP_REST_Server#remove_header method and uses it to clear the Last-Modified header when the "no caching" headers are sent (by default for all authenticated REST API requests). This matches the behavior of the nocache_headers function used in other parts of WordPress.

Previously, the REST API would send an empty Last-Modified header in this situation. Under some server and browser configurations, this causes browsers to cache authenticated REST API requests, which is undesirable.

Props iv3rson76, zinigor, rmccue, jnylen0.
Fixes #40444.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/spy-rest-server.php

    r39343 r40805  
    3030    public function send_header( $header, $value ) {
    3131        $this->sent_headers[ $header ] = $value;
     32    }
     33
     34    public function remove_header( $header ) {
     35        unset( $this->sent_headers[ $header ] );
    3236    }
    3337
Note: See TracChangeset for help on using the changeset viewer.