diff --git a/src/application/config/config.php b/src/application/config/config.php index 51becf70..31bc13d7 100644 --- a/src/application/config/config.php +++ b/src/application/config/config.php @@ -262,6 +262,18 @@ $config['log_date_format'] = 'Y-m-d H:i:s'; */ $config['cache_path'] = __DIR__ . '/../../storage/cache/'; +/* +|-------------------------------------------------------------------------- +| Cache Busting Token +|-------------------------------------------------------------------------- +| +| This token will be appending to asset URLs in order to invalidate the browser +| cache and enforce end clients to fetch new files. Update the token with each +| new release. +| +*/ +$config['cache_busting_token'] = 'dfsg8s09df8g098'; + /* |-------------------------------------------------------------------------- | Encryption Key diff --git a/src/application/helpers/asset_helper.php b/src/application/helpers/asset_helper.php new file mode 100644 index 00000000..fee0378b --- /dev/null +++ b/src/application/helpers/asset_helper.php @@ -0,0 +1,29 @@ + + * @copyright Copyright (c) 2013 - 2017, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.3.0 + * ---------------------------------------------------------------------------- */ + +/** + * Assets URL helper function. + * + * This function will create an asset file URL that includes a cache busting parameter in order + * to invalidate the browser cache in case of an update. + * + * @param string $uri Relative URI (just like the one used in the base_url helper). + * @param string|null $protocol Valid URI protocol. + * + * @return string Returns the final asset URL. + */ +function asset_url($uri = '', $protocol = NULL) { + $ci =& get_instance(); + + return base_url($uri . '?' . $ci->config->item('cache_busting_token'), $protocol); +}