modifier.prevent_cache.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 
12 /**
13  * Prevent caching of a response by adding a unique parameter to the url.
14  *
15  * Example:
16  * @code
17  * {$url|prevent_cache}
18  *
19  * {$url|prevent_cache:"ts"}
20  * @endcode
21  *
22  * @param $url The url
23  * @param $name The parameter name (optional, default: unique)
24  */
25 function smarty_modifier_prevent_cache($url, $name='unique') {
26  return $url.'?'.$name.'='.uniqid((double)microtime()*1000000, 1);
27 }
28 ?>