Bust Cache Macro
Installation
Via Composer:
$ composer require nepada/bust-cache
Register the extension in config.neon
:
extensions:
- Nepada\Bridges\BustCacheDI\BustCacheExtension(%wwwDir%, %debugMode%)
If you're using stand-alone Latte, install the macro manually:
$latte->addMacro('bustCache', new Nepada\BustCache\BustCacheMacro($wwwDir, $debugMode));
Usage
Example:
<link rel="stylesheet" href="{bustCache /css/style.css}">
In debug mode the macro busts cache by appending timestamp of last file modification:
<link rel="stylesheet" href="/css/style.css?1449177985">
In production mode the macro busts cache by appending first 10 letters of md5 hash of the file content:
<link rel="stylesheet" href="/css/style.css?a1d0c6e83f">
Note: It is not recommended (but supported) to pass variables into the macro, because they need to be resolved in run-time and thus the file is read on every request.
-
v2.1.0 2.1.0
- Requires Latte 2.5 and optionally Nette 3.0 (Nette 2.4 support was dropped).
-
v2.0.2 2.0.2
- Fixed compatibility with Latte 2.5
-
v2.0.1 2.0.1
- Fixed compatibility with Latte 2.5
- Initial support for Nette DI 3.0
- CI improvements
-
v2.0.0 2.0.0
- Refactored exception hierarchy - unlikely, but possible BC break.
- Code style and type safety improvements.
-
v1.1.1 1.1.1
- Code style improvements.
-
v1.1.0 1.1.0
- Requires Latte 2.4 and PHP 7.1.
- Uses
declare(strict_types = 1)
. - Uses scalar and return type hints.
- Compatible with PHP 7.2.
-
v1.0.1 1.0.1
- Code style improvements.
- Tests against Nette 2.4.
-
v1.0.0 1.0.0
- Initial release.