Making WordPress.org


Ignore:
Timestamp:
04/01/2020 03:03:01 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Switch the locale banner to a GET request and cache the request for up-to 1 hour.

See #3604.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-locale-banner.php

    r9667 r9668  
    1414        function __construct() {
    1515                register_rest_route( 'plugins/v1', '/locale-banner', array(
    16                         'methods'  => WP_REST_Server::EDITABLE,
     16                        'methods'  => WP_REST_Server::ALLMETHODS,
    1717                        'callback' => array( $this, 'locale_banner' ),
    1818                        'args'     => array(
     
    210210                }
    211211
    212                 $result = [
     212                $result = new \WP_REST_Response( [
    213213                        'suggest_string' => $suggest_string,
    214214                        'translated'     => $translated_locales,
    215                 ];
     215                ] );
     216
     217                // Allow this API to be cached, varied by Accept-Language header.
     218                $result->header( 'Vary', 'Accept-Language' );
     219                $result->header( 'Expires', gmdate( 'r', time() + 3600 ) );
     220                $result->header( 'Cache-Control', 'max-age=3600' );
    216221
    217222                return $result;
Note: See TracChangeset for help on using the changeset viewer.