staabm / http-cache-control
一个提供文档化的常量和HTTP Cache-Control头示例用例的小型库。
1.0
2022-04-11 11:55 UTC
Requires
- php: ^7.2 || ^8.0
README
一个提供文档化的常量和示例用例的小型库,用于HTTP Cache-Control
头,基于官方cloudflare文档。
发送正确的Cache-Control头对于每个Web应用至关重要,但所需的关键词有时可能会引起误导和模糊不清。这个库旨在提供一种更可靠和一致的方式来设置Cache-Control头。
示例
use staabm\HttpCacheControl\Constants; use staabm\HttpCacheControl\UseCase; class MyController { public function sendPdf(string $pdfFile) { header(Constants::CACHE_CONTROL .':'. UseCase::cacheOnBrowserAndProxyRequireProxyRevalidation()); readfile($pdfFile); } public function sendGdpr(string $pdfFile) { header(Constants::CACHE_CONTROL_CLOUDFLARE .':'. UseCase::cacheOnBrowserAndProxyForDifferentTime(300, 3600)); readfile($pdfFile); } }