guzzle-cache-middleware icon indicating copy to clipboard operation
guzzle-cache-middleware copied to clipboard

Adapters ignore cache headers (expires / cache-control)

Open firegore opened this issue 6 years ago • 7 comments

The DoctrineAdapter does not check the Cache-Control / Expire Header if the content should be cached at all.

firegore avatar Dec 15 '17 12:12 firegore

Hi @firegore! Currently, no adapter take into account the cache headers. The adapters can only be configured with a default cache duration.

In any case, feel free to make a PR, if you wish this feature implemented! :)

csarrazi avatar Jan 16 '18 13:01 csarrazi

There's a guzzle middleware that does that, but it has to be manually integrated with the CsaGuzzleBundle yourself, or switch to the bundle it is designed for.

andreicio avatar Mar 08 '20 08:03 andreicio

Hum, I think it would be interesting to provide a means to have plugins in the bundle itself.

csarrazi avatar Apr 15 '20 15:04 csarrazi

I'll give it a shot. I'd like to discuss the implementation with you before I start though. I'll send you an email with a proposal.

andreicio avatar Apr 15 '20 15:04 andreicio

Sure, no problem! Or this can be discussed here if you prefer. I don't really mind ;)

csarrazi avatar Apr 20 '20 08:04 csarrazi

The package I linked to in my earlier comment is not the middleware itself, but rather a plugin package that integrates the kevinrob/guzzle-cache-middleware in the EightPointsGuzzleBundle. That bundle is another package that integrates guzzle in symfony, offering plugin configuration per client, instead of globally, but sacrifices ease of integration. It is much harder to integrate existing middleware with the 8p solution.

In the case of the CsaGuzzleBundle, using kevinrob's middleware can be done simply by registering the desired services and tagging the middleware appropriately. I could write a simple bundle that would do that and offer a simple configuration, to avoid including it in the main guzzle bundle as another built-in plugin. On the other hand I believe that it would add unneeded code, since, as I said, all that is required is some service declarations. I see now that you would like to simplify support for 3rd party middleware. You already have a readme page on the subject, and to be honest I don't see how you could simplify it further. Let's use this example and see what could be improved, if anything.

andreicio avatar Apr 20 '20 14:04 andreicio

True. What I'd like to be able to do at some point is to let people configure middleware independently or override middleware configuration for a given client.

One thing to note though is that some things might be a little bit tricky to configure unless these middleware have a factory to initialize them (things like injecting services inside clients).

csarrazi avatar Apr 27 '20 09:04 csarrazi