granam/assets-version

将其版本号注入到其URL中

安装: 264

依赖项: 2

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

语言:CSS

2.1.1 2021-07-27 06:35 UTC

This package is auto-updated.

Last update: 2024-08-27 14:15:26 UTC


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"/>
*/