This repository was archived by the owner on Jun 27, 2022. It is now read-only.
File tree 1 file changed +7
-8
lines changed
1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -44,14 +44,7 @@ public static function getDirective(MessageInterface $message, $part)
44
44
public static function getResponseAge (ResponseInterface $ response )
45
45
{
46
46
if ($ response ->hasHeader ('Age ' )) {
47
- $ age = (int ) $ response ->getHeader ('Age ' );
48
-
49
- // Increment the age based on the X-Guzzle-Cache-Date
50
- if ($ cacheDate = $ response ->getHeader ('X-Guzzle-Cache-Date ' )) {
51
- $ age += (time () - strtotime ($ cacheDate ));
52
- }
53
-
54
- return $ age ;
47
+ return (int ) $ response ->getHeader ('Age ' );
55
48
}
56
49
57
50
$ date = strtotime ($ response ->getHeader ('Date ' ) ?: 'now ' );
@@ -179,6 +172,12 @@ public static function isResponseValid(
179
172
$ responseAge = Utils::getResponseAge ($ response );
180
173
$ maxAge = Utils::getDirective ($ response , 'max-age ' );
181
174
175
+ // Increment the age based on the X-Guzzle-Cache-Date
176
+ if ($ cacheDate = $ response ->getHeader ('X-Guzzle-Cache-Date ' )) {
177
+ $ responseAge += (time () - strtotime ($ cacheDate ));
178
+ $ response ->setHeader ('Age ' , $ responseAge );
179
+ }
180
+
182
181
// Check the request's max-age header against the age of the response
183
182
if ($ maxAge !== null && $ responseAge > $ maxAge ) {
184
183
return false ;
You can’t perform that action at this time.
0 commit comments