Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"X-Kevinrob-Cache: MISS" although response is from cache #140

Open
rincler opened this issue Apr 20, 2021 · 1 comment
Open

"X-Kevinrob-Cache: MISS" although response is from cache #140

rincler opened this issue Apr 20, 2021 · 1 comment

Comments

@rincler
Copy link

rincler commented Apr 20, 2021

Hi!

I have two layers of cache: memory and redis:

...
$stack->push(
  new CacheMiddleware(new GreedyCacheStrategy(new VolatileRuntimeStorage(), 0)),
  'identity-map'
);

$stack->push(
  new CacheMiddleware(new GreedyCacheStrategy(new Psr16CacheStorage($redisCache), 60)),
  'cache'
);
...

Suggest we have cached response in redis. We make $client->request().
I expect: X-Kevinrob-Cache: HIT
I see: X-Kevinrob-Cache: MISS

redis middleware set X-Kevinrob-Cache to HIT in

$cacheEntry->getResponse()->withHeader(self::HEADER_CACHE_INFO, self::HEADER_CACHE_HIT)
, but then memory middleware set X-Kevinrob-Cache to MISS in
$response = $response->withHeader(self::HEADER_CACHE_INFO, self::HEADER_CACHE_MISS);

Maybe need to check X-Kevinrob-Cache header before set it to MISS ?

@Kevinrob
Copy link
Owner

Kevinrob commented Jul 4, 2021

You can use ChainCache for using multiple cache storage.
But we can change for checking the presence of the header before setting it! Would you like to make a PR about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants