Skip to content
Cache busting macro for Latte.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitattributes
.gitignore
.phpcs.xml.dist
.travis.yml
LICENSE.md
README.md
composer.json
phpstan.neon.dist
phpstan.tests.neon.dist

README.md

Bust Cache Macro

Build Status Coverage Status Downloads this Month Latest stable

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.

You can’t perform that action at this time.