1. Go to this page and download the library: Download smartondev/httpcache 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/ */
smartondev / httpcache example snippets
use SmartonDev\HttpCache\Builders\CacheHeaderBuilder;
// max-age 1 hour, private, no-store
$headers = (new CacheHeaderBuilder())
->maxAge(hours: 1)
->private()
->noStore()
->toHeaders();
// max-age 60 sec, shared max age 120 sec, stale-while-revalidate 30 sec
$headers = (new CacheHeaderBuilder())
->maxAge(60)
->sharedMaxAge(120)
->staleWhileRevalidate(30)
->toHeaders();
$noCacheHeaders = (new CacheHeaderBuilder())
->noCache()
->toHeaders();