Aggressive Caching with Symfony HTTP Client

JoliCode - JoliCodeBlog - 01/03
The Symfony CachingHttpClient The HttpClient component comes with a client that can cache responses when possible. It means the client won’t issue another request to the server if the response is already available in the cache. It works like your browser by reading some headers like

Section intitulée the-symfony-cachinghttpclientThe Symfony CachingHttpClient

The HttpClient component comes with a client that can cache responses when possible. It means the client won’t issue another request to the server if the response is already available in the cache. It works like your browser by reading some headers like cache-control or expires

Unfortunately, this client is not enabled by default. You must configure it manually.

If you are using the component directly:

$httpClient = new Symfony\Component\HttpClient\CachingHttpClient( Symfony\Component\HttpClient\HttpClient::create() new Symfony\Component\HttpKernel\HttpCache\Store('/path/to/cache') );

The CachingHttpClient acts as a decorator for the regular HttpClient. It also implemen...
[Courte citation de 8% de l'article original]

Loading...