缓存:页面缓存、空间缓存、数据缓存。smarty中的缓存就是页面缓存 smarty的缓存是页面缓存。 开启缓存- $smarty->caching=true|1; //开启缓存
复制代码 1.10.2 缓存的更新方法一:删除缓存,系统会重新生成新的缓存文件 方法二:更新了模板文件,配置文件,缓存自动更新 方法三:过了缓存的生命周期,默认是3600秒 方法四:强制更新 PHP代码 - <?php
- require './Smarty/smarty.class.php';
- $smarty=new Smarty();
- $smarty->caching=true; //开启缓存
- if(date('H')>=9)
- $smarty->force_cache=true; //强制更新缓存
- $smarty->display('6-demo.html');
复制代码 缓存的生命周期- $smarty->cache_lifetime=-1 | 0 | N
- -1:永远不过期
- 0:立即过期
- N:有效期是N秒,默认是3600秒
复制代码 PHP代码
- $smarty->cache_lifetime=3; //缓存的生命周期
复制代码
|