Posts, Post Types: Add no-cache headers to password protected posts.

This instructs an intermediate cache, for example a proxy server, to not cache a password protected post both before and after a visitor has entered a password.

Props brevilo, haozi, ironprogrammer, narenin

Fixes #61711
Built from https://develop.svn.wordpress.org/trunk@59728


git-svn-id: http://core.svn.wordpress.org/trunk@59070 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2025-01-29 18:12:25 +00:00
parent 7b5f5f727a
commit 87d88ab387
2 changed files with 6 additions and 1 deletions

View File

@ -545,6 +545,11 @@ class WP {
if ( $post && pings_open( $post ) ) {
$headers['X-Pingback'] = get_bloginfo( 'pingback_url', 'display' );
}
// Send nocache headers for password protected posts to avoid unwanted caching.
if ( ! empty( $post->post_password ) ) {
$headers = array_merge( $headers, wp_get_nocache_headers() );
}
}
/**

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.8-alpha-59727';
$wp_version = '6.8-alpha-59728';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.