function HttpCache::__construct
Constructor.
The available options are:
- debug If true, exceptions are thrown when things go wrong. Otherwise, the cache will try to carry on and deliver a meaningful response.
- trace_level May be one of 'none', 'short' and 'full'. For 'short', a concise trace of the main request will be added as an HTTP header. 'full' will add traces for all requests (including ESI subrequests). (default: 'full' if in debug; 'none' otherwise)
- trace_header Header name to use for traces. (default: X-Symfony-Cache)
- default_ttl The number of seconds that a cache entry should be considered fresh when no explicit freshness information is provided in a response. Explicit Cache-Control or Expires headers override this value. (default: 0)
- private_headers Set of request headers that trigger "private" cache-control behavior on responses that don't explicitly state whether the response is public or private via a Cache-Control directive. (default: Authorization and Cookie)
- skip_response_headers Set of response headers that are never cached even if a response is cacheable (public). (default: Set-Cookie)
- allow_reload Specifies whether the client can force a cache reload by including a Cache-Control "no-cache" directive in the request. Set it to ``true`` for compliance with RFC 2616. (default: false)
- allow_revalidate Specifies whether the client can force a cache revalidate by including a Cache-Control "max-age=0" directive in the request. Set it to ``true`` for compliance with RFC 2616. (default: false)
- stale_while_revalidate Specifies the default number of seconds (the granularity is the second as the Response TTL precision is a second) during which the cache can immediately return a stale response while it revalidates it in the background (default: 2). This setting is overridden by the stale-while-revalidate HTTP Cache-Control extension (see RFC 5861).
- stale_if_error Specifies the default number of seconds (the granularity is the second) during which the cache can serve a stale response when an error is encountered (default: 60). This setting is overridden by the stale-if-error HTTP Cache-Control extension (see RFC 5861).
File
-
vendor/
symfony/ http-kernel/ HttpCache/ HttpCache.php, line 85
Class
- HttpCache
- Cache provides HTTP caching.
Namespace
Symfony\Component\HttpKernel\HttpCacheCode
public function __construct(HttpKernelInterface $kernel, StoreInterface $store, ?SurrogateInterface $surrogate = null, array $options = []) {
// needed in case there is a fatal error because the backend is too slow to respond
register_shutdown_function($this->store
->cleanup(...));
$this->options = array_merge([
'debug' => false,
'default_ttl' => 0,
'private_headers' => [
'Authorization',
'Cookie',
],
'skip_response_headers' => [
'Set-Cookie',
],
'allow_reload' => false,
'allow_revalidate' => false,
'stale_while_revalidate' => 2,
'stale_if_error' => 60,
'trace_level' => 'none',
'trace_header' => 'X-Symfony-Cache',
], $options);
if (!isset($options['trace_level'])) {
$this->options['trace_level'] = $this->options['debug'] ? 'full' : 'none';
}
}