| 148 |
lars |
1 |
\$caching {#variable.caching}
|
|
|
2 |
=========
|
|
|
3 |
|
|
|
4 |
This tells Smarty whether or not to cache the output of the templates to
|
|
|
5 |
the [`$cache_dir`](#variable.cache.dir). By default this is set to the
|
|
|
6 |
constant Smarty::CACHING\_OFF. If your templates consistently generate
|
|
|
7 |
the same content, it is advisable to turn on `$caching`, as this may
|
|
|
8 |
result in significant performance gains.
|
|
|
9 |
|
|
|
10 |
You can also have [multiple](#caching.multiple.caches) caches for the
|
|
|
11 |
same template.
|
|
|
12 |
|
|
|
13 |
- A constant value of Smarty::CACHING\_LIFETIME\_CURRENT or
|
|
|
14 |
Smarty::CACHING\_LIFETIME\_SAVED enables caching.
|
|
|
15 |
|
|
|
16 |
- A value of Smarty::CACHING\_LIFETIME\_CURRENT tells Smarty to use
|
|
|
17 |
the current [`$cache_lifetime`](#variable.cache.lifetime) variable
|
|
|
18 |
to determine if the cache has expired.
|
|
|
19 |
|
|
|
20 |
- A value of Smarty::CACHING\_LIFETIME\_SAVED tells Smarty to use the
|
|
|
21 |
[`$cache_lifetime`](#variable.cache.lifetime) value at the time the
|
|
|
22 |
cache was generated. This way you can set the
|
|
|
23 |
[`$cache_lifetime`](#variable.cache.lifetime) just before
|
|
|
24 |
[fetching](#api.fetch) the template to have granular control over
|
|
|
25 |
when that particular cache expires. See also
|
|
|
26 |
[`isCached()`](#api.is.cached).
|
|
|
27 |
|
|
|
28 |
- If [`$compile_check`](#variable.compile.check) is enabled, the
|
|
|
29 |
cached content will be regenerated if any of the templates or config
|
|
|
30 |
files that are part of this cache are changed.
|
|
|
31 |
|
|
|
32 |
- If [`$force_compile`](#variable.force.compile) is enabled, the
|
|
|
33 |
cached content will always be regenerated.
|
|
|
34 |
|
|
|
35 |
See also [`$cache_dir`](#variable.cache.dir),
|
|
|
36 |
[`$cache_lifetime`](#variable.cache.lifetime),
|
|
|
37 |
[`$cache_modified_check`](#variable.cache.modified.check),
|
|
|
38 |
[`is_cached()`](#api.is.cached) and the [caching section](#caching).
|