nocache_headers

Set the headers to prevent caching for the different browsers.

Description

nocache_headers(); 

Different browsers support different nocache headers, so several headers must be sent so that all of them get the point that no caching should occur.


Usage

  1. if ( !function_exists( 'nocache_headers' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = nocache_headers(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function nocache_headers() { 
  2. $headers = wp_get_nocache_headers(); 
  3.  
  4. unset( $headers['Last-Modified'] ); 
  5.  
  6. // In PHP 5.3+, make sure we are not sending a Last-Modified header. 
  7. if ( function_exists( 'header_remove' ) ) { 
  8. @header_remove( 'Last-Modified' ); 
  9. } else { 
  10. // In PHP 5.2, send an empty Last-Modified header, but only as a 
  11. // last resort to override a header already sent. #WP23021 
  12. foreach ( headers_list() as $header ) { 
  13. if ( 0 === stripos( $header, 'Last-Modified' ) ) { 
  14. $headers['Last-Modified'] = ''; 
  15. break; 
  16.  
  17. foreach ( $headers as $name => $field_value ) 
  18. @header("{$name}: {$field_value}");