jeroenvdheuve / assetic-cache-busting-worker-bundle
此包已被废弃且不再维护。未建议替代包。
Assetic 缓存重命名工作包。使用 assetic 缓存重命名工作来根据文件内容向文件名添加哈希值。
v1.0.3
2016-03-09 08:03 UTC
Requires
- jeroenvdheuve/assetic-cache-busting-worker: ~1.0
- symfony/config: ~2.3|~3.0
- symfony/dependency-injection: ~2.3|~3.0
- symfony/http-kernel: ~2.3|~3.0
- symfony/yaml: ~2.3|~3.0
Requires (Dev)
- phpunit/phpunit: >=4,<6
Suggests
- jeroenvdheuve/assetic-cached-worker: Assetic cached worker can make twig cache generation faster. Each asset is only compiled once and cached is used after the first time.
This package is not auto-updated.
Last update: 2023-05-27 10:30:30 UTC
README
描述
此包使得自动更改受 assetic 控制的文件(如 JavaScript 样式表文件)的文件名变得容易。CacheBustingWorker 会向文件名添加哈希值。这个哈希值是通过文件内容生成的。因为这个 CacheBustingWorker 不使用文件修改时间来生成哈希值,所以它也适用于不关心文件修改时间的系统(如 git)。
通过注册此包并启用配置文件来启用此包。
# AppKernel.php public function registerBundles() { $bundles = array( ... new jvdh\AsseticCacheBustingBundle\JvdhAsseticCacheBustingBundle() ); }
通过配置文件启用。
# app/config/config.yml jvdh_assetic_cache_busting: enabled: true
哈希分隔符用于分隔文件和哈希。破折号 / - 是默认分隔符。当压缩 javascript.js 文件时,CacheBustingWorker 将名称更改为 javascript-HASH.js
# app/config/config.yml jvdh_assetic_cache_busting: enabled: true separator: -
默认的哈希长度为 8 个字符。当增加哈希长度时,请始终检查哈希算法是否可以生成这么长的哈希值。例如,md5 只能生成 32 个字符的哈希值。
# app/config/config.yml jvdh_assetic_cache_busting: enabled: true hash_length: 32
默认的哈希算法为 sha1。任何受 PHP 函数 hash
支持的哈希算法都可以使用。使用不同的算法可能会提高生成文件名更改的速度。
# app/config/config.yml jvdh_assetic_cache_busting: enabled: true hash_algorithm: md5
当生产环境中的文件名只需包含哈希值时,可以在生产模式下仅注册此包。还可以在例如 app/config/config_prod.yml
文件中启用缓存重命名,该文件只在生产模式下加载。