wp_get_nocache_headers

The timeline below displays how wordpress function wp_get_nocache_headers has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Gets the HTTP header information to prevent caching.
 *
 * The several different headers cover the different ways cache prevention
 * is handled by different browsers.
 *
 * @since 2.8.0
 * @since 6.3.0 The `Cache-Control` header for logged in users now includes the
 *              `no-store` and `private` directives.
 *
 * @return array The associative array of header names and field values.
 */
function wp_get_nocache_headers()
{
    $cache_control = (function_exists('is_user_logged_in') && is_user_logged_in()) ? 'no-cache, must-revalidate, max-age=0, no-store, private' : 'no-cache, must-revalidate, max-age=0';
    $headers = array('Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control' => $cache_control);
    if (function_exists('apply_filters')) {
        /**
         * Filters the cache-controlling HTTP headers that are used to prevent caching.
         *
         * @since 2.8.0
         *
         * @see wp_get_nocache_headers()
         *
         * @param array $headers Header names and field values.
         */
        $headers = (array) apply_filters('nocache_headers', $headers);
    }
    $headers['Last-Modified'] = false;
    return $headers;
}

WordPress Version: 6.1

/**
 * Gets the header information to prevent caching.
 *
 * The several different headers cover the different ways cache prevention
 * is handled by different browsers
 *
 * @since 2.8.0
 *
 * @return array The associative array of header names and field values.
 */
function wp_get_nocache_headers()
{
    $headers = array('Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control' => 'no-cache, must-revalidate, max-age=0');
    if (function_exists('apply_filters')) {
        /**
         * Filters the cache-controlling headers.
         *
         * @since 2.8.0
         *
         * @see wp_get_nocache_headers()
         *
         * @param array $headers Header names and field values.
         */
        $headers = (array) apply_filters('nocache_headers', $headers);
    }
    $headers['Last-Modified'] = false;
    return $headers;
}

WordPress Version: 4.6

/**
 * Get the header information to prevent caching.
 *
 * The several different headers cover the different ways cache prevention
 * is handled by different browsers
 *
 * @since 2.8.0
 *
 * @return array The associative array of header names and field values.
 */
function wp_get_nocache_headers()
{
    $headers = array('Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control' => 'no-cache, must-revalidate, max-age=0');
    if (function_exists('apply_filters')) {
        /**
         * Filters the cache-controlling headers.
         *
         * @since 2.8.0
         *
         * @see wp_get_nocache_headers()
         *
         * @param array $headers {
         *     Header names and field values.
         *
         *     @type string $Expires       Expires header.
         *     @type string $Cache-Control Cache-Control header.
         * }
         */
        $headers = (array) apply_filters('nocache_headers', $headers);
    }
    $headers['Last-Modified'] = false;
    return $headers;
}

WordPress Version: 4.0

/**
 * Get the header information to prevent caching.
 *
 * The several different headers cover the different ways cache prevention
 * is handled by different browsers
 *
 * @since 2.8.0
 *
 * @return array The associative array of header names and field values.
 */
function wp_get_nocache_headers()
{
    $headers = array('Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', 'Pragma' => 'no-cache');
    if (function_exists('apply_filters')) {
        /**
         * Filter the cache-controlling headers.
         *
         * @since 2.8.0
         *
         * @see wp_get_nocache_headers()
         *
         * @param array $headers {
         *     Header names and field values.
         *
         *     @type string $Expires       Expires header.
         *     @type string $Cache-Control Cache-Control header.
         *     @type string $Pragma        Pragma header.
         * }
         */
        $headers = (array) apply_filters('nocache_headers', $headers);
    }
    $headers['Last-Modified'] = false;
    return $headers;
}

WordPress Version: 3.9

/**
 * Gets the header information to prevent caching.
 *
 * The several different headers cover the different ways cache prevention is handled
 * by different browsers
 *
 * @since 2.8.0
 *
 * @return array The associative array of header names and field values.
 */
function wp_get_nocache_headers()
{
    $headers = array('Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', 'Pragma' => 'no-cache');
    if (function_exists('apply_filters')) {
        /**
         * Filter the cache-controlling headers.
         *
         * @since 2.8.0
         *
         * @param array $headers {
         *     Header names and field values.
         *
         *     @type string $Expires       Expires header.
         *     @type string $Cache-Control Cache-Control header.
         *     @type string $Pragma        Pragma header.
         * }
         */
        $headers = (array) apply_filters('nocache_headers', $headers);
    }
    $headers['Last-Modified'] = false;
    return $headers;
}

WordPress Version: 3.8

/**
 * Gets the header information to prevent caching.
 *
 * The several different headers cover the different ways cache prevention is handled
 * by different browsers
 *
 * @since 2.8.0
 *
 * @return array The associative array of header names and field values.
 */
function wp_get_nocache_headers()
{
    $headers = array('Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', 'Pragma' => 'no-cache');
    if (function_exists('apply_filters')) {
        $headers = (array) apply_filters('nocache_headers', $headers);
    }
    $headers['Last-Modified'] = false;
    return $headers;
}

WordPress Version: 3.7

/**
 * Gets the header information to prevent caching.
 *
 * The several different headers cover the different ways cache prevention is handled
 * by different browsers
 *
 * @since 2.8.0
 *
 * @uses apply_filters()
 * @return array The associative array of header names and field values.
 */
function wp_get_nocache_headers()
{
    $headers = array('Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', 'Pragma' => 'no-cache');
    if (function_exists('apply_filters')) {
        $headers = (array) apply_filters('nocache_headers', $headers);
    }
    $headers['Last-Modified'] = false;
    return $headers;
}