From 0453bdf58cee0a571803760a1c3e68ff5dd04a5a Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 3 Sep 2018 20:56:00 +0200 Subject: [PATCH] add view_cache_safe() for https://github.com/opnsense/ui_devtools/issues/3 as a result of https://github.com/opnsense/core/issues/2367 --- stubs/index.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/stubs/index.php b/stubs/index.php index 2f0e52e..ce19ae6 100644 --- a/stubs/index.php +++ b/stubs/index.php @@ -72,6 +72,21 @@ function view_file_exists($filename) return file_exists($filename); } +/** + * return appended version string with a hash for proper caching for currently installed version + * @param string $url to make cache-safe + * @return string + */ +function view_cache_safe($url) +{ + $myview = \Phalcon\DI::getDefault()->get('view'); + if (!empty($myview->product_hash)) { + return "{$url}?v={$myview->product_hash}"; + } + return $url; +} + + try { /** * Read the configuration