PHP code example of componenta / http-cache

1. Go to this page and download the library: Download componenta/http-cache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

componenta / http-cache example snippets


use Componenta\Http\Cache\Attribute\CacheResponse;

#[CacheResponse(
    ttl: 60,
    varyHeaders: ['Accept-Language'],
    tags: ['catalog'],
)]
final class CatalogHandler
{
    public function __invoke(): mixed
    {
        // ...
    }
}

new HttpCachePolicy(
    ttl: 60,
    private: true,
    allowAuthenticated: true,
);

ConfigKey::MAX_ENTRY_BYTES => 8_388_608,

ConfigKey::DEBUG_HEADER => true,