File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727use Psr \Http \Message \ResponseInterface ;
2828use Psr \Http \Message \UriInterface ;
2929
30+ use function strtolower ;
31+
3032/**
3133 * @Flow\Scope("singleton")
3234 */
@@ -256,10 +258,18 @@ protected function requestJson(Uri $uri): PromiseInterface
256258 $ uriString = (string )$ uri ;
257259
258260 $ headers = $ this ->getRequestHeaders ($ uriString );
261+
259262 $ headersForCacheIdentifier = [];
263+ $ storeResponse = true ;
264+
260265 foreach ($ headers as $ key => $ value ) {
266+ $ key = strtolower ($ key );
267+ if ($ key === 'cache-control ' && strtolower ($ value ) === 'no-store ' ) {
268+ $ storeResponse = false ;
269+ }
261270 $ headersForCacheIdentifier [] = sprintf ('%s: %s ' , $ key , $ value );
262271 }
272+
263273 $ cacheIdentifier = md5 (serialize ($ headersForCacheIdentifier ) . '| ' . $ uriString );
264274
265275 if ($ this ->requestsCache ->has ($ cacheIdentifier )) {
@@ -269,8 +279,10 @@ protected function requestJson(Uri $uri): PromiseInterface
269279 } else {
270280 $ response = $ this
271281 ->fetch ($ uri , $ headers )
272- ->then (function (string $ result ) use ($ cacheIdentifier ) {
273- $ this ->requestsCache ->set ($ cacheIdentifier , $ result );
282+ ->then (function (string $ result ) use ($ cacheIdentifier , $ storeResponse ) {
283+ if (!$ storeResponse ) {
284+ $ this ->requestsCache ->set ($ cacheIdentifier , $ result );
285+ }
274286 return $ result ;
275287 });
276288 }
You can’t perform that action at this time.
0 commit comments