codemonauts/craft-asset-autoversioning
Composer 安装命令:
composer require codemonauts/craft-asset-autoversioning
包简介
A Twig extension for Craft CMS that helps you cache-bust your assets.
README 文档
README
A really basic Twig extension for CraftCMS that helps you cache-bust your assets.
Background
To force the browser to download the new asset file after a update, the plugin allows you to add a Twig function, which adds the build number or the filemtime to the filename.
Requirements
- Craft CMS >= 4.0.0
Installation
Project
Open your terminal and go to your Craft project:
cd /path/to/project
composer require codemonauts/craft-asset-autoversioning
./craft install/plugin craft3-assets-autoversioning
CI/CD Pipeine
The build number which gets added to the asset URL is read from a file called build.txt which must exist in your project folder. Use for example something like this in your deployment script (Example is for CodeShip):
echo -n "${CI_BUILD_NUMBER}" > build.txt
If the file doesn't exists, the filemtime of the asset is used.
Webserver
Because the clients will from now on start to request files like /css/styles.12345678.css we need to tell the webserver how to rewrite these URLs so that the original /css/styles.css will get served.
Apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?\/)*?([a-z\.\-]+)(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$ $1$2$4 [L]
</IfModule>
NGINX
location ~* (.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif|webp)$ { try_files $uri $1.$2; }
Usage
Use the new Twig function versioning() in your template. For example in pug:
<link rel="stylesheet" href="{{ versioning('/css/styles.css')}}">
will result in something like this:
<link rel="stylesheet" href="/css/styles.12345678.css">
With ❤ by codemonauts
codemonauts/craft-asset-autoversioning 适用场景与选型建议
codemonauts/craft-asset-autoversioning 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.44k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 12 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「assets」 「cache」 「cms」 「Craft」 「craftcms」 「craft-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codemonauts/craft-asset-autoversioning 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codemonauts/craft-asset-autoversioning 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codemonauts/craft-asset-autoversioning 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Asset Management for PHP
repository php library
Caching and compression for Twig assets (JavaScript and CSS).
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
统计信息
- 总下载量: 18.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-19
