-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ on: | |
- 'LICENSE' | ||
- 'CHANGELOG.md' | ||
- 'CONTRIBUTING.md' | ||
- 'doc/**' | ||
|
||
jobs: | ||
phpunit: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ on: | |
- 'LICENSE' | ||
- 'CHANGELOG.md' | ||
- 'CONTRIBUTING.md' | ||
- 'doc/**' | ||
|
||
jobs: | ||
phpunit: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# `CacheHeaderBuilder` class | ||
|
||
The `CacheHeaderBuilder` class is used to build cache headers like `Cache-Control`, `ETag`. | ||
|
||
## Usage | ||
|
||
### No-cache | ||
|
||
Strongly no caching. No caching in browser, no caching in proxy. | ||
|
||
Recommended for sensitive data or data that changes frequently. | ||
|
||
```php | ||
$noCacheHeaders = (new CacheHeaderBuilder()) | ||
->noCache() | ||
->toHeaders(); | ||
``` | ||
|
||
### Caching in browser in private mode | ||
|
||
Caching in browser for 1 hour. No caching in proxy. | ||
|
||
```php | ||
$headers = (new CacheHeaderBuilder()) | ||
->maxAge(hours: 1) | ||
->private() | ||
->toHeaders(); | ||
``` | ||
|
||
### Caching public | ||
|
||
Caching in browser (and in proxy) for 1 hour. | ||
|
||
```php | ||
$headers = (new CacheHeaderBuilder()) | ||
->maxAge(hours: 1) | ||
->public() | ||
->toHeaders(); | ||
``` | ||
|
||
### Caching in CDN | ||
|
||
Caching in CDN for 60 seconds, shared max age 30 seconds. | ||
|
||
```php | ||
$headers = (new CacheHeaderBuilder()) | ||
->maxAge(30) | ||
->public() | ||
->sharedMaxAge(60) | ||
->toHeaders(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# `ETagHeaderBuilder` class | ||
|
||
The `ETagHeaderBuilder` class is used to build the `ETag` header. | ||
|
||
The `ETag` header is a string that uniquely identifies a specific version of a resource. It is used to determine if the | ||
resource has changed since the last request. | ||
|
||
## Usage | ||
|
||
### Week ETag | ||
|
||
Generate a week ETag. The ETag will be a hash of the content and not represent the real version of the resource. | ||
|
||
```php | ||
$headers = (new ETagHeaderBuilder()) | ||
->withEtag('123456') | ||
->withWeekEtag() | ||
->toHeaders(); | ||
``` | ||
|
||
### ETag | ||
|
||
Generate a strong ETag. The ETag will be a hash of the content and represent the real version of the resource. | ||
|
||
```php | ||
$headers = (new ETagHeaderBuilder()) | ||
->etag('123456') | ||
->toHeaders(); | ||
``` | ||
|
||
### ETag from content | ||
|
||
Generate a strong ETag from the content with a specific hash algorithm. | ||
|
||
```php | ||
$headers = (new ETagHeaderBuilder()) | ||
->computedETag($content, 'md5') | ||
->toHeaders(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# `ETagMatcher` class | ||
|
||
The `ETagMatcher` class is used to match the `ETag` header of the request like `If-Match`, `If-None-Match`. | ||
|
||
## Usage | ||
|
||
### If-Match | ||
|
||
... | ||
|
||
### If-None-Match | ||
|
||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# `ModifiedMatcher` class | ||
|
||
The `ModifiedMatcher` class is used to check if the request headers contain the `If-Modified-Since` header and if the | ||
last modified date is greater than the date in the header. | ||
|
||
Additionally, it can check if the request headers contain the `If-Unmodified-Since` header and if the last modified date | ||
is less than or equal to the date in the header. | ||
|
||
## Usage | ||
|
||
### If-Modified-Since | ||
|
||
Check if the resource has been modified since the date specified in the `If-Modified-Since` header. | ||
|
||
... | ||
|
||
### If-Unmodified-Since | ||
|
||
Check if the resource has not been modified since the date specified in the `If-Unmodified-Since` header. | ||
|
||
... | ||
|