bvdputte/kirby-fingerprint
最新稳定版本:2.2.5
Composer 安装命令:
composer require bvdputte/kirby-fingerprint
包简介
Cache-busting utility to fingerprint assets (JS/CSS) in Kirby 3
README 文档
README
A little utility to add cache-busting fingerprints to assets (JS/CSS) in Kirby CMS.
Re-uses the css() and js()-helpers in Kirby as much as possible.
When the files are updated, new hashes are added to the filenames automatically; so browser cache gets busted.
Installation
- unzip master.zip as folder
site/plugins/kirby-fingerprintor git submodule add https://github.com/bvdputte/kirby-fingerprint.git site/plugins/kirby-fingerprintcomposer require bvdputte/kirby-fingerprint
Apache .htaccess rules
💡 Add the following to your .htaccess file:
# Bust browsercache on CSS & JS files
# More info: https://github.com/bvdputte/kirby-fingerprint
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.([0-9a-z]{32})\.(js|css|png|jpe?g|gif|svg|ico)$ $1.$3 [L]
Place immediately after the RewriteBase definition.
Nginx rules
Add the following to your virtual host setup:
location ~ (.+)\.(?:[0-9,a-z]+)\.(js|css)$ {
try_files $uri $1.$2;
}
Usage
css("assets/css/styles.css"); // Output: <link href="//localhost:3000/assets/css/styles.db5796ea5bf253bb7be3526eb083e068.css" rel="stylesheet"> js("assets/js/scripts.js"); // Output: <script src="//localhost:3000/assets/js/scripts.1e9dd0c95e7b12ce96729501c7585deb.js"></script>
Options
- Disable plugin:
// config.php return [ 'bvdputte.fingerprint.disabled' => true ];
- Use a parameter instead of a hashed filename:
// config.php return [ 'bvdputte.fingerprint.parameter' => true ];
This can be useful in situations where you don't want/can work with rewrites (e.g. in Laravel Valet). If possible; don't use parameters in production environment, use hashed filenames instead.
Advanced features
For more advanced features, such as subresource integrity, please checkout bnomei's kirby3-fingerprint plugin.
Disclaimer
This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.
License
It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.
统计信息
- 总下载量: 9.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-14