Changeset 59724
- Timestamp:
- 01/28/2025 11:20:48 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r59712 r59724 1490 1490 * 1491 1491 * 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. 1493 1493 * 1494 1494 * @since 2.8.0 1495 1495 * @since 6.3.0 The `Cache-Control` header for logged in users now includes the 1496 1496 * `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. 1497 1499 * 1498 1500 * @return array The associative array of header names and field values. 1499 1501 */ 1500 1502 function 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'; 1504 1504 1505 1505 $headers = array( -
trunk/tests/e2e/specs/cache-control-headers-directives.test.js
r56926 r59724 28 28 await context.close(); 29 29 30 expect( responseHeaders ).toEqual( expect.not.objectContaining( { "cache-control": "no-cache" } ) ); 30 31 expect( responseHeaders ).toEqual( expect.not.objectContaining( { "cache-control": "no-store" } ) ); 31 32 expect( responseHeaders ).toEqual( expect.not.objectContaining( { "cache-control": "private" } ) ); … … 41 42 const responseHeaders = response.headers(); 42 43 44 expect( responseHeaders[ 'cache-control' ] ).toContain( 'no-cache' ); 45 expect( responseHeaders[ 'cache-control' ] ).toContain( 'no-store' ); 46 expect( responseHeaders[ 'cache-control' ] ).toContain( 'private' ); 47 } ); 48 49 test( 50 'Correct directives present in cache control header when not logged in on 404 page.', 51 async ( { browser } 52 ) => { 53 const context = await browser.newContext(); 54 const loggedOutPage = await context.newPage(); 55 56 const response = await loggedOutPage.goto( '/this-does-not-exist/' ); 57 const responseHeaders = response.headers(); 58 const responseStatus = response.status(); 59 60 // Dispose context once it's no longer needed. 61 await context.close(); 62 63 expect( responseStatus ).toBe( 404 ); 64 expect( responseHeaders[ 'cache-control' ] ).toContain( 'no-cache' ); 43 65 expect( responseHeaders[ 'cache-control' ] ).toContain( 'no-store' ); 44 66 expect( responseHeaders[ 'cache-control' ] ).toContain( 'private' );
Note: See TracChangeset
for help on using the changeset viewer.