instantjay / cachebustphp
用于缓存破坏超链接资源的轻量级库
1.1.0
2020-02-28 13:27 UTC
Requires
- php: ^7.1
- symfony/filesystem: ^5.0
- symfony/finder: ^5.0
- symfony/http-foundation: ^5.0
Requires (Dev)
- mockery/mockery: ^1.3
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-09-28 23:17:29 UTC
README
使用此库,最好配合您选择的模板引擎,轻松地将缓存破坏令牌字符串附加到您的超链接资源,例如样式表或JavaScript文件。
用法
$fileService = new FileService('/var/mysite/public/');
$tokenType = new ResourceSizeHashToken();
$queryStringBuster = new QueryStringBuster($tokenType, $fileService);
$queryStringBuster->modifyResourcePath('css/stylesheet.min.css');
输出:css/stylesheet.min.css?token=...
,其中令牌基于文件大小哈希生成,每次文件本身更新时都会改变。