wp_get_nocache_headers

Get the header information to prevent caching.

Description

(array) wp_get_nocache_headers(); 

The several different headers cover the different ways cache prevention is handled by different browsers

Returns (array)

The associative array of header names and field values.


Usage

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

Defined (1)

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

/wp-includes/functions.php  
  1. function wp_get_nocache_headers() { 
  2. $headers = array( 
  3. 'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',  
  4. 'Cache-Control' => 'no-cache, must-revalidate, max-age=0',  
  5. ); 
  6.  
  7. if ( function_exists('apply_filters') ) { 
  8. /** 
  9. * Filters the cache-controlling headers. 
  10. * @since 2.8.0 
  11. * @see wp_get_nocache_headers() 
  12. * @param array $headers { 
  13. * Header names and field values. 
  14. * @type string $Expires Expires header. 
  15. * @type string $Cache-Control Cache-Control header. 
  16. * } 
  17. */ 
  18. $headers = (array) apply_filters( 'nocache_headers', $headers ); 
  19. $headers['Last-Modified'] = false; 
  20. return $headers;