From dcce352ffd23cbac6c955be9ea1ab33beeb12780 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 18 May 2014 23:45:44 +0200 Subject: [PATCH] Improved assets cache handling URLs of stylesheets and scripts are appended with current engine version. This forces browsers to aggressively refresh the assets regardless of any caching settings, whenever new version comes out. --- src/Helpers/Assets.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Helpers/Assets.php b/src/Helpers/Assets.php index 678de702..1a798740 100644 --- a/src/Helpers/Assets.php +++ b/src/Helpers/Assets.php @@ -16,12 +16,12 @@ class Assets extends \Chibi\Util\Assets public function addStylesheet($path) { - return parent::addStylesheet('/media/css/' . $path); + return parent::addStylesheet($this->decorateUrl('/media/css/' . $path)); } public function addScript($path) { - return parent::addScript('/media/js/' . $path); + return parent::addScript($this->decorateUrl('/media/js/' . $path)); } public function transformHtml($html) @@ -47,4 +47,10 @@ class Assets extends \Chibi\Util\Assets $html = str_replace('', $bodySnippet . '', $html); return $html; } + + + private function decorateUrl($url) + { + return $url . '?' . PropertyModel::get(PropertyModel::EngineVersion); + } }