granam / assets-version
将其版本号注入到其URL中
2.1.1
2021-07-27 06:35 UTC
Requires
- php: >=7.3
- granam/strict-object: ~3.0
Requires (Dev)
- phpunit/phpunit: ~9.2
README
不再有浏览器缓存惊喜,不再需要强制页面刷新来获取最新的样式、图片、javascripts...
给我HTML页面或只是一部分,我将返回带有附加到资产URL上的md5值的“版本”。
composer require granam/assets-version
$assetsVersionInjector = new \Granam\AssetsVersion\AssetsVersionInjector(); $contentWithVersions = $assetsVersionInjector->addVersionsToAssetLinks( <<<HTML <link href="/assets/css/bootstrap-v3.4.1.css" rel="stylesheet" type="text/css"/><!--this will be ignored due to a excluding regexp--> <link href="/assets/css/style.css" rel="stylesheet" type="text/css"/> <link href="/assets/css/perex.css" rel="stylesheet" type="text/css"/> HTML , '~\d+[.]\d+[.]\d+~', // exclude links with version-like names __DIR__ . '/web' ); /* <link href="/assets/css/bootstrap-v3.4.1.css" rel="stylesheet" type="text/css"/><!--this will be ignored due to a excluding regexp--> <link href="/assets/css/style.css?version=f395e65bcd4671fc77ce01c521c9e29a" rel="stylesheet" type="text/css"/> <link href="/assets/css/perex.css?version=7ace2a8e3e0501c9539760a0e08d9378" rel="stylesheet" type="text/css"/> */