Make WordPress Core


Ignore:
Timestamp:
01/28/2025 11:20:48 PM (13 months ago)
Author:
johnbillion
Message:

Security: Always include the no-store and private directives in the Cache-Control header when setting headers that prevent caching.

The intention of these headers is to prevent any form of caching, whether that's in the browser or in an intermediate cache such as a proxy server. These directives instruct an intermediate cache to not store the response in their cache for any user – not just for logged-in users.

This does not affect the caching behaviour of assets within a page such as images, CSS, and JavaScript files.

Props kkmuffme, devansh2002, johnbillion.

Fixes #61942

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r59712 r59724  
    14901490 *
    14911491 * The several different headers cover the different ways cache prevention
    1492  * is handled by different browsers.
     1492 * is handled by different browsers or intermediate caches such as proxy servers.
    14931493 *
    14941494 * @since 2.8.0
    14951495 * @since 6.3.0 The `Cache-Control` header for logged in users now includes the
    14961496 *              `no-store` and `private` directives.
     1497 * @since 6.8.0 The `Cache-Control` header now includes the `no-store` and `private`
     1498 *              directives regardless of whether a user is logged in.
    14971499 *
    14981500 * @return array The associative array of header names and field values.
    14991501 */
    15001502function wp_get_nocache_headers() {
    1501     $cache_control = ( function_exists( 'is_user_logged_in' ) && is_user_logged_in() )
    1502         ? 'no-cache, must-revalidate, max-age=0, no-store, private'
    1503         : 'no-cache, must-revalidate, max-age=0';
     1503    $cache_control = 'no-cache, must-revalidate, max-age=0, no-store, private';
    15041504
    15051505    $headers = array(
Note: See TracChangeset for help on using the changeset viewer.