Make WordPress Core


Ignore:
Timestamp:
02/21/2009 09:39:06 PM (16 years ago)
Author:
westi
Message:

Allow for the HTTP headers returned by WordPress to be filtered by a plugin. Fixes #9205 props filosofo.

File:
1 edited

Legend:

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

    r10617 r10619  
    14611461
    14621462/**
     1463 * Gets the header information to prevent caching.
     1464 *
     1465 * The several different headers cover the different ways cache prevention is handled
     1466 * by different browsers
     1467 *
     1468 * @since 2.8
     1469 *
     1470 * @uses apply_filters()
     1471 * @return array The associative array of header names and field values.
     1472 */
     1473function wp_get_nocache_headers() {
     1474    $headers = array(
     1475        'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',
     1476        'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT',
     1477        'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
     1478        'Pragma' => 'no-cache',
     1479    );
     1480    return apply_filters('nocache_headers', $headers); 
     1481}
     1482
     1483/**
    14631484 * Sets the headers to prevent caching for the different browsers.
    14641485 *
     
    14671488 *
    14681489 * @since 2.0.0
     1490 * @uses wp_get_nocache_headers()
    14691491 */
    14701492function nocache_headers() {
    1471     // why are these @-silenced when other header calls aren't?
    1472     @header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
    1473     @header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
    1474     @header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
    1475     @header( 'Pragma: no-cache' );
     1493    $headers = wp_get_nocache_headers();
     1494    foreach( (array) $headers as $name => $field_value )
     1495        @header("{$name}: {$field_value}");     
    14761496}
    14771497
Note: See TracChangeset for help on using the changeset viewer.