CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 07:59:21 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/symfony/symfony.git
etag: W/"d8e9cabac02126774d13a84b8f652380"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=%2F4Ngq4heQJ41ZFi2MyZI2yk1rA0LaRblovRYPLuozyWSNxqnVO%2FPzUAODU7auTEb4PAZDIdp4v6%2BknOxDnelvtqOgFgnxiNWI7cl%2Bt0CGVqgrSPZ9HVsV5olkRTns16Pxov9OhNNhe420INL2s%2F8E7PFGymw5qH3PNz15ThoEpDcjBcrKUUZJjYXf%2Fp3YU%2F5Gwwqb3HEAmbGvXH4V34dn628IEt052qIdqmSCkqN3QEo4W5bNpOgeprAHf7s7pb%2FWnxrdVVSGRZlGTEQ6rMe%2BQ%3D%3D--3vJycVX8E5isnzYD--xFrW9SZNG4nrTHkgaewF9g%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.751773240.1760255960; Path=/; Domain=github.com; Expires=Mon, 12 Oct 2026 07:59:20 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 12 Oct 2026 07:59:20 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 9F72:27D4FB:2C63E9:3D6090:68EB5FD8
feature #59576 [HttpClient] Make `CachingHttpClient` compatible with … · symfony/symfony@9c413a3 · GitHub
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.php
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
Copy file name to clipboard
Copy file name to clipboard
Copy file name to clipboard
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit 9c413a3
committed
feature #59576 [HttpClient] Make
This PR was squashed before being merged into the 7.4 branch.
Discussion
----------
[HttpClient] Make `CachingHttpClient` compatible with RFC 9111
| Q | A
| ------------- | ---
| Branch? | 7.3
| Bug fix? | no
| New feature? | yes
| Deprecations? | yes
| Issues | Fix #36858 Fix #49937 Fix #41843 Fix #61588
| License | MIT
This PR brings [RFC9111](https://www.rfc-editor.org/rfc/rfc9111.html) support to `CachingHttpClient` by leveraging `symfony/cache`. It provides caching for `GET` and `HEAD` requests, and cache invalidation for `POST`, `PUT`, `DELETE`, `PATCH`.
The implementation is **asynchronous**, so the response **must be consumed** (e.g., via getContent() or streaming) for caching to occur.
### Basic usage
```php
// Create the base HTTP client
$baseClient = HttpClient::create();
// Create a cache backend (e.g., Filesystem cache)
$cache = new FilesystemAdapter();
// Instantiate the CachingHttpClient
$client = new CachingHttpClient(
client: $baseClient,
cache: $cache,
defaultOptions: [], // Optional default options
sharedCache: true, // Use a shared cache (default)
maxTtl: 86400 // Maximum cache TTL in seconds (optional)
);
// Make a request
$response = $client->request('GET', 'https://api.example.com/data');
// Get the response content
$content = $response->getContent();
```
### Constructor parameters
- `$client`: The underlying HTTP client.
- `$cache`: A cache backend implementing `TagAwareCacheInterface`.
- `$defaultOptions`: An optional array of default request options.
- `$sharedCache`: `true` to indicate the cache is [shared](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Caching#shared_cache), `false` for [private](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Caching#private_caches). Defaults to true.
- `$maxTtl`: Optional maximum time-to-live (in seconds) for cached responses. If set, server-provided TTLs are capped to this value.
### Omissions from RFC9111
- The following cache-control directives are not supported and thus ignored : `stale-while-revalidate`, `min-fresh`, `max-stale`, and `only-if-cached`. In the case of `stale-while-revalidate`, a stale response will always be revalidated.
- Range requests and partial content (206 status, Range/Content-Range headers) are not supported; requests with Range headers bypass caching.
### Integration with FrameworkBundle
```yaml
framework:
http_client:
caching:
cache_pool: my_taggable_pool
shared: true
max_ttl: 86400
scoped_clients:
caching_client:
base_uri: 'https://symfony.com'
caching:
cache_pool: my_taggable_pool
```
It is also **highly recommended** to configure a retry strategy to automatically retry the request in case of cache inconsistency.
Commits
-------
a62b547 [HttpClient] Make `CachingHttpClient` compatible with RFC 9111CachingHttpClient
compatible with RFC 9111 (Lctrs)File tree
Expand file treeCollapse file tree
17 files changed
+1914
-99
lines changedFilter options
- src/Symfony
- Bundle/FrameworkBundle
- DependencyInjection
- Resources/config
- schema
- Tests/DependencyInjection
- Fixtures
- php
- xml
- yml
- Component/HttpClient
- Caching
- Exception
- Tests
Expand file treeCollapse file tree
17 files changed
+1914
-99
lines changedCollapse file: UPGRADE-7.4.md
+1Lines changed: 1 addition & 0 deletions
- Display the source diff
- Display the rich diff
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
| 60 | + | |
60 | 61 |
| |
61 | 62 |
| |
62 | 63 |
| |
|
Collapse file: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md+1Lines changed: 1 addition & 0 deletions
- Display the source diff
- Display the rich diff
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| 15 | + | |
15 | 16 |
| |
16 | 17 |
| |
17 | 18 |
| |
|
Collapse file: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php+29Lines changed: 29 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1995 | 1995 |
| |
1996 | 1996 |
| |
1997 | 1997 |
| |
| 1998 | + | |
1998 | 1999 |
| |
1999 | 2000 |
| |
2000 | 2001 |
| |
| |||
2140 | 2141 |
| |
2141 | 2142 |
| |
2142 | 2143 |
| |
| 2144 | + | |
2143 | 2145 |
| |
2144 | 2146 |
| |
2145 | 2147 |
| |
| |||
2150 | 2152 |
| |
2151 | 2153 |
| |
2152 | 2154 |
| |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
2153 | 2182 |
| |
2154 | 2183 |
| |
2155 | 2184 |
| |
|
Collapse file: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php+32Lines changed: 32 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
93 | 93 |
| |
94 | 94 |
| |
95 | 95 |
| |
| 96 | + | |
| 97 | + | |
96 | 98 |
| |
97 | 99 |
| |
98 | 100 |
| |
| |||
2770 | 2772 |
| |
2771 | 2773 |
| |
2772 | 2774 |
| |
| 2775 | + | |
| 2776 | + | |
2773 | 2777 |
| |
2774 | 2778 |
| |
2775 | 2779 |
| |
| |||
2793 | 2797 |
| |
2794 | 2798 |
| |
2795 | 2799 |
| |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
2796 | 2804 |
| |
2797 | 2805 |
| |
2798 | 2806 |
| |
| |||
2818 | 2826 |
| |
2819 | 2827 |
| |
2820 | 2828 |
| |
| 2829 | + | |
| 2830 | + | |
2821 | 2831 |
| |
2822 | 2832 |
| |
2823 | 2833 |
| |
| |||
2841 | 2851 |
| |
2842 | 2852 |
| |
2843 | 2853 |
| |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
2844 | 2858 |
| |
2845 | 2859 |
| |
2846 | 2860 |
| |
| |||
2882 | 2896 |
| |
2883 | 2897 |
| |
2884 | 2898 |
| |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
2885 | 2917 |
| |
2886 | 2918 |
| |
2887 | 2919 |
| |
|
Collapse file: src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.php
src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.php
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.php+9Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
| 18 | + | |
18 | 19 |
| |
19 | 20 |
| |
20 | 21 |
| |
| |||
25 | 26 |
| |
26 | 27 |
| |
27 | 28 |
| |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
28 | 37 |
| |
29 | 38 |
| |
30 | 39 |
| |
|
Collapse file: src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd+9Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
730 | 730 |
| |
731 | 731 |
| |
732 | 732 |
| |
| 733 | + | |
733 | 734 |
| |
734 | 735 |
| |
735 | 736 |
| |
| |||
757 | 758 |
| |
758 | 759 |
| |
759 | 760 |
| |
| 761 | + | |
760 | 762 |
| |
761 | 763 |
| |
762 | 764 |
| |
| |||
790 | 792 |
| |
791 | 793 |
| |
792 | 794 |
| |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
793 | 802 |
| |
794 | 803 |
| |
795 | 804 |
| |
|
Collapse file: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_caching.php
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_caching.php
Copy file name to clipboard+24Lines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + |
Collapse file: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_caching.xml
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_caching.xml
Copy file name to clipboard+21Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + |
Collapse file: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_caching.yml
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_caching.yml
Copy file name to clipboard+19Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + |
Collapse file: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php+35Lines changed: 35 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
| 57 | + | |
| 58 | + | |
57 | 59 |
| |
58 | 60 |
| |
59 | 61 |
| |
| |||
2185 | 2187 |
| |
2186 | 2188 |
| |
2187 | 2189 |
| |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
2188 | 2223 |
| |
2189 | 2224 |
| |
2190 | 2225 |
| |
|
You can’t perform that action at this time.
0 commit comments