instantjay / cachebustphp
Small library for cache busting your hyperlinked resources
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: 2025-01-29 00:03:28 UTC
README
Use this library, preferrably with your templating engine of choice, to easily append a cache busting token string to your hyperlinked resource, such as a stylesheet or a javascript file.
Usage
$fileService = new FileService('/var/mysite/public/');
$tokenType = new ResourceSizeHashToken();
$queryStringBuster = new QueryStringBuster($tokenType, $fileService);
$queryStringBuster->modifyResourcePath('css/stylesheet.min.css');
Will output: css/stylesheet.min.css?token=...
with a token generated based on file size hash, which will then
change every time the file itself gets updated.