Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Hergen Dillema committed Jun 3, 2021
1 parent 7d5107b commit 947743c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "werk365/etagconditionals",
"description": "Laravel package to enable support for ETags and handling If-Match and If-None-Match conditional requests",
"version": "1.1.0",
"version": "1.2.0",
"license": "MIT",
"authors": [
{
Expand Down
17 changes: 17 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ return [
```
Or by setting the ENV values above.

### Defining custom ETags
The static method `EtagConditionals::etagGenerateUsing()` allows you to have full control over how your Etag is generated by passing a callback as argument.
This means you can do simple things like returning an ETag using a different algorithm, or other custom solutions.
```php
EtagConditionals::etagGenerateUsing(function (\Symfony\Component\HttpFoundation\Response $response) {
return hash('sha256', $response->getContent());
});
```
```php
EtagConditionals::etagGenerateUsing(function (\Illuminate\Http\Request $request, \Symfony\Component\HttpFoundation\Response $response) {
return Cache::rememberForever('etag.'.$request->url(), function () use ($response) {
return md5($response->getContent());
});
});
```


## Change log


Expand Down

0 comments on commit 947743c

Please sign in to comment.