Kevinrob / guzzle-cache-middleware

A HTTP Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caching POST requests

popkin opened this issue · comments

is it posible to cache POST requests?

thanks in advance

First thing, it's not a good idea to cache POST requests. POST requests exists for "posting" something, they have to reach the server.

But some server don't implement POST correctly... By default only GET is allowed to be cached (by the RFC too).
You can add others methods with setHttpMethods(array $methods) on CacheMiddleware like that:

$cache = new CacheMiddleware();
$cache->setHttpMethods(['GET' => true, 'POST' => true]);

yeah, this server uses POST even for getting data :( it's a nightmare.

I'll try that, thanks