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.
This commit is contained in:
Marcin Kurczewski 2014-05-18 23:45:44 +02:00
parent 3e426844a8
commit dcce352ffd

View file

@ -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('</body>', $bodySnippet . '</body>', $html);
return $html;
}
private function decorateUrl($url)
{
return $url . '?' . PropertyModel::get(PropertyModel::EngineVersion);
}
}