You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/CachePlugin.php
+49-8Lines changed: 49 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -34,31 +34,52 @@ final class CachePlugin implements Plugin
34
34
*/
35
35
private$config;
36
36
37
+
/**
38
+
* Cache directives indicating if a response can be cached
39
+
*
40
+
* @var array
41
+
*/
42
+
private$noCacheFlags = ['no-cache', 'private'];
43
+
37
44
/**
38
45
* @param CacheItemPoolInterface $pool
39
46
* @param StreamFactory $streamFactory
40
47
* @param array $config {
41
48
*
42
-
* @var bool $respect_cache_headers Whether to look at the cache directives or ignore them
49
+
* @var bool $respect_cache_headers Whether to look at the cache directives or ignore them. This option is deprecated, use `respect_response_cache_directives` instead
43
50
* @var int $default_ttl (seconds) If we do not respect cache headers or can't calculate a good ttl, use this
44
51
* value
45
52
* @var string $hash_algo The hashing algorithm to use when generating cache keys
46
53
* @var int $cache_lifetime (seconds) To support serving a previous stale response when the server answers 304
47
54
* we have to store the cache for a longer time than the server originally says it is valid for.
48
55
* We store a cache item for $cache_lifetime + max age of the response.
49
56
* @var array $methods list of request methods which can be cached.
57
+
* @var array $respect_response_cache_directives list of cache directives this plugin will respect while caching responses.
if (isset($config['respect_cache_headers']) && $config['respect_response_cache_directives']) {
66
+
thrownew \InvalidArgumentException('You can\'t provide config option "respect_cache_headers" and "respect_response_cache_directives". Use "respect_response_cache_directives" instead.');
* This method will setup the cachePlugin in client cache mode. When using the client cache mode the plugin will cache responses with `private` cache directive
@@ -76,6 +97,15 @@ public static function clientCache(CacheItemPoolInterface $pool, StreamFactory $
76
97
returnnewself($pool, $streamFactory, $config);
77
98
}
78
99
100
+
/**
101
+
* This method will setup the cachePlugin in server cache mode. This is the default caching behavior (refuses to cache responses with the `private`or `no-cache` directives
0 commit comments