wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_get_nocache_headers › WordPress Function

Seit2.8.0
Veraltetn/v
wp_get_nocache_headers ( Keine Parameter )
Gibt zurück:
  • (array) The associative array of header names and field values.
Definiert in:
Codex:
Changelog:
  • 6.3.0

Gets the HTTP header information to prevent caching.

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


Quellcode

function wp_get_nocache_headers() {
	$cache_control = ( function_exists( 'is_user_logged_in' ) && is_user_logged_in() )
		? 'no-cache, must-revalidate, max-age=0, no-store, private'
		: 'no-cache, must-revalidate, max-age=0';

	$headers = array(
		'Expires'       => 'Wed, 11 Jan 1984 05:00:00 GMT',
		'Cache-Control' => $cache_control,
	);

	if ( function_exists( 'apply_filters' ) ) {
		/**
		 * Filters the cache-controlling HTTP headers that are used to prevent caching.
		 *
		 * @since 2.8.0
		 *
		 * @see wp_get_nocache_headers()
		 *
		 * @param array $headers Header names and field values.
		 */
		$headers = (array) apply_filters( 'nocache_headers', $headers );
	}
	$headers['Last-Modified'] = false;
	return $headers;
}