Skip to content

Commit 346b28b

Browse files
committed
readme updated
1 parent 42fc735 commit 346b28b

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ php artisan vendor:publish --provider="Chr15k\ResponseCompression\ResponseCompre
2424

2525
This package provides the following middleware:
2626

27-
#### 1. Compression Middleware
27+
#### Compression Middleware
2828

2929
Applies Gzip or Brotli compression to HTTP responses based on client support. This reduces the size of the response payload and enhances load times.
3030

3131
**Ideal For**: Large JSON responses, static files, or data-intensive endpoints.
3232

33+
> [!WARNING]
34+
> When using Brotli, a client-side decoding error may occur with non-secure connections, as modern browsers generally support Brotli compression only over HTTPS.
35+
3336
---
3437

3538
## Setup
@@ -66,6 +69,49 @@ Route::get('/profile', function () {
6669

6770
---
6871

72+
## Config
73+
74+
```php
75+
/**
76+
* Enable or disable the response compression.
77+
*/
78+
'enabled' => env('RESPONSE_COMPRESSION_ENABLED', true),
79+
80+
/**
81+
* The compression algorithm to use. Can be either 'gzip' or 'br'.
82+
*/
83+
'algorithm' => env('RESPONSE_COMPRESSION_ALGORITHM', 'gzip'),
84+
85+
/**
86+
* The minimum length of the response content to be compressed.
87+
*/
88+
'min_length' => env('RESPONSE_COMPRESSION_MIN_LENGTH', 1024),
89+
90+
'gzip' => [
91+
/**
92+
* The level of compression. Can be given as 0 for no compression up to 9
93+
* for maximum compression. If not given, the default compression level will
94+
* be the default compression level of the zlib library.
95+
*
96+
* @see https://www.php.net/manual/en/function.gzencode.php
97+
*/
98+
'level' => env('RESPONSE_COMPRESSION_GZIP_LEVEL', 5),
99+
],
100+
101+
'br' => [
102+
/**
103+
* The level of compression. Can be given as 0 for no compression up to 11
104+
* for maximum compression. If not given, the default compression level will
105+
* be the default compression level of the brotli library.
106+
*
107+
* @see https://www.php.net/manual/en/function.brotli-compress.php
108+
*/
109+
'level' => env('RESPONSE_COMPRESSION_BROTLI_LEVEL', 5),
110+
]
111+
```
112+
113+
---
114+
69115
## Testing
70116

71117
```bash

0 commit comments

Comments
 (0)