Skip to content

Commit 257b561

Browse files
Add ETag-only cache mode (#96)
1 parent c7fd57a commit 257b561

6 files changed

Lines changed: 881 additions & 422 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
# Version 2
44

5+
## 2.1.0 - TBD
6+
7+
### Added
8+
9+
- Added `EtagCachePlugin` to cache only ETag-backed responses and always revalidate them before serving cached bodies.
10+
511
## 2.0.2 - 2025-12-01
612

713
- Support Symfony 8.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ composer require php-http/cache-plugin
2323

2424
Please see the [official documentation](http://docs.php-http.org/en/latest/plugins/cache.html).
2525

26+
To only cache ETag-backed responses and always revalidate cached bodies with `If-None-Match`, use `EtagCachePlugin`:
27+
28+
``` php
29+
$plugin = EtagCachePlugin::clientCache($pool, $streamFactory);
30+
```
31+
32+
Responses without an `ETag` header are not cached. Cached responses are only returned after the origin replies with `304 Not Modified`.
33+
2634

2735
## Testing
2836

0 commit comments

Comments
 (0)