Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coverals-and-codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
php-version: '8.5'
coverage: xdebug

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
php-version: [ 8.2, 8.3, 8.4 ]
php-version: [ 8.2, 8.3, 8.4, 8.5 ]

steps:
- name: Checkout code
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
php-version: [ 8.2, 8.3, 8.4 ]
php-version: [ 8.2, 8.3, 8.4, 8.5 ]

steps:
- name: Checkout code
Expand All @@ -34,4 +34,4 @@ jobs:
run: echo "xdebug.mode=coverage" >> $GITHUB_ENV

- name: Run PHPStan (level 10 / src)
run: vendor/bin/phpstan analyse -l 10 src
run: vendor/bin/phpstan analyse -l max src
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ $builder = (new CacheHeaderBuilder())
```php
use SmartonDev\HttpCache\Matchers\ETagMatcher;

// ETag check
// ETag check with If-None-Match header
$etagMatcher = (new ETagMatcher())
->headers($requestHeaders);
$activeEtag = '1234';
if($etagMatcher->matches($activeEtag)->matches()) {
$activeEtag = '"1234"';
if($etagMatcher->matches($activeEtag)->matchesIfNoneMatchHeader()) {
// 304 Not Modified
return response(null, 304);
}
Expand All @@ -82,11 +82,11 @@ if($etagMatcher->matches($activeEtag)->matches()) {
```php
use SmartonDev\HttpCache\Matchers\ModifiedMatcher;

// modified since
// Check If-Modified-Since header
$modifiedMatcher = (new ModifiedMatcher())
->headers($requestHeaders);
if($modifiedMatcher->matches($lastModified)->matchesModifiedAt()) {
// 304 Not Modified
if(!$modifiedMatcher->matches($lastModified)->isModifiedSince()) {
// 304 Not Modified - resource hasn't been modified
return response(null, 304);
}
```
Expand Down
25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
"description": "Simple HTTP cache management library",
"type": "library",
"license": "Apache-2.0",
"keywords": [
"http",
"cache",
"caching",
"http-cache",
"etag",
"cache-control",
"last-modified",
"http-headers"
],
"homepage": "https://github.com/smartondev/httpcache",
"support": {
"issues": "https://github.com/smartondev/httpcache/issues",
"source": "https://github.com/smartondev/httpcache"
},
"authors": [
{
"name": "Márton Somogyi",
Expand All @@ -17,6 +32,8 @@
"pestphp/pest": "^3.7",
"mockery/mockery": "^1.6"
},
"minimum-stability": "stable",
"prefer-stable": true,
"autoload": {
"psr-4": {
"SmartonDev\\HttpCache\\": "src/"
Expand All @@ -27,9 +44,17 @@
"SmartonDev\\HttpCache\\Tests\\": "tests/"
}
},
"scripts": {
"test": "pest",
"test:coverage": "pest --coverage",
"analyse": "phpstan analyse src --level=max"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
},
"platform": {
"php": "8.2.0"
}
}
}
Loading