@@ -265,6 +265,9 @@ following methods::
265
265
// you can get individual info too
266
266
$startTime = $response->getInfo('start_time');
267
267
268
+ .. tip ::
269
+ Call ``$response->getInfo('debug') `` to get detailed logs about the HTTP transaction.
270
+
268
271
.. _http-client-streaming-responses :
269
272
270
273
Streaming Responses
@@ -316,17 +319,23 @@ When the HTTP status code of the response is in the 300-599 range (i.e. 3xx,
316
319
Caching Requests and Responses
317
320
------------------------------
318
321
319
- This component provides a special HTTP client via the
320
- :class: `Symfony\\ Component\\ HttpClient\\ CachingHttpClient ` class to cache
321
- requests and their responses. The actual HTTP caching is implemented using the
322
- :doc: `HttpKernel component </components/http_kernel >`, so make sure it's
323
- installed in your application.
322
+ This component provides a :class: `Symfony\\ Component\\ HttpClient\\ CachingHttpClient `
323
+ decorator that allows caching responses and serving them from the local storage
324
+ for next requests. The implementation leverages the
325
+ :class: `Symfony\\ Component\\ HttpKernel\\ HttpCache\\ HttpCache ` class under the hood
326
+ so that the :doc: `HttpKernel component </components/http_kernel >` needs to be
327
+ installed in your application::
324
328
325
- ..
326
- .. TODO:
327
- .. Show some example of caching requests+responses
328
- ..
329
- ..
329
+ use Symfony\Component\HttpClient\HttpClient;
330
+ use Symfony\Component\HttpClient\CachingHttpClient;
331
+ use Symfony\Component\HttpKernel\HttpCache\Store;
332
+
333
+ $store = new Store('/path/to/cache/storage/');
334
+ $client = HttpClient::create();
335
+ $client = new CachingHttpClient($client, $store);
336
+
337
+ // this won't hit the network if the resource is already in the cache
338
+ $response = $client->request('GET', 'https://example.com/cacheable-resource');
330
339
331
340
Scoping Client
332
341
--------------
0 commit comments