diff --git a/docs/en/programmers/caching/caching-cacheable.xml b/docs/en/programmers/caching/caching-cacheable.xml
index a9d0809c..a2a5b923 100644
--- a/docs/en/programmers/caching/caching-cacheable.xml
+++ b/docs/en/programmers/caching/caching-cacheable.xml
@@ -2,22 +2,22 @@
Controlling Cacheability of Plugins' Output
-
+
Since Smarty-2.6.0 plugins the cacheability of plugins can be declared
when registering them. The third parameter to register_block,
register_compiler_function and register_function is called
$cacheable and defaults to true which is also
the behaviour of plugins in Smarty versions before 2.6.0
-
+
-
+
When registering a plugin with $cacheable=false the plugin is
called everytime the page is displayed, even if the page comes
from the cache. The plugin function behaves a little like an
insert function.
-
+
-
+
In contrast to {insert}
the attributes to the plugins are not cached by default. They can be
declared to be cached with the fourth parameter
@@ -25,9 +25,9 @@
is an array of attribute-names that should be cached, so the
plugin-function get value as it was the time the page was written
to cache everytime it is fetched from the cache.
-
+
-
+ Preventing a plugin's output from being cached
endtime}
]]>
-
+
The number of seconds till the endtime of $obj is reached changes on
each display of the page, even if the page is cached. Since the
endtime attribute is cached the object only has to be pulled from the
database when page is written to the cache but not on subsequent requests
of the page.
-
+
-
+ Preventing a whole passage of a template from being cached
-
+
-
+
When reloading the page you will notice that both dates differ. One
is "dynamic" one is "static". You can do everything between
{dynamic}...{/dynamic} and be sure it will not be cached like the rest
of the page.
-
+
diff --git a/docs/en/programmers/caching/caching-groups.xml b/docs/en/programmers/caching/caching-groups.xml
index 893acd26..77cfda6b 100644
--- a/docs/en/programmers/caching/caching-groups.xml
+++ b/docs/en/programmers/caching/caching-groups.xml
@@ -2,14 +2,14 @@
Cache Groups
-
- You can do more elaborate grouping by setting up cache_id groups. This is
- accomplished by separating each sub-group with a vertical bar "|" in the
- cache_id value. You can have as many sub-groups as you like.
-
-
- cache_id groups
-
+
+ You can do more elaborate grouping by setting up cache_id groups. This is
+ accomplished by separating each sub-group with a vertical bar "|" in the
+ cache_id value. You can have as many sub-groups as you like.
+
+
+ cache_id groups
+
clear_cache(null,"sports");
$smarty->display('index.tpl',"sports|basketball");
?>
]]>
-
-
-
- Technical Note
-
- The cache grouping does NOT use the path to the template as any part of the
- cache_id. For example, if you have display('themes/blue/index.tpl'), you
- cannot clear the cache for everything under the "themes/blue" directory. If
- you want to do that, you must group them in the cache_id, such as
- display('themes/blue/index.tpl','themes|blue'); Then you can clear the
- caches for the blue theme with clear_cache(null,'themes|blue');
-
-
-
+
+
+
+ Technical Note
+
+ The cache grouping does NOT use the path to the template as any part of the
+ cache_id. For example, if you have display('themes/blue/index.tpl'), you
+ cannot clear the cache for everything under the "themes/blue" directory. If
+ you want to do that, you must group them in the cache_id, such as
+ display('themes/blue/index.tpl','themes|blue'); Then you can clear the
+ caches for the blue theme with clear_cache(null,'themes|blue');
+
+
+
+
+
\ No newline at end of file
+-->
diff --git a/docs/en/programmers/caching/caching-multiple-caches.xml b/docs/en/programmers/caching/caching-multiple-caches.xml
index 0fd9f02b..e1f2e5d7 100644
--- a/docs/en/programmers/caching/caching-multiple-caches.xml
+++ b/docs/en/programmers/caching/caching-multiple-caches.xml
@@ -2,13 +2,13 @@
Multiple Caches Per Page
-
- You can have multiple cache files for a single call to display() or
- fetch(). Let's say that a call to display('index.tpl') may have several
- different output contents depending on some condition, and you want
- separate caches for each one. You can do this by passing a cache_id as the
- second parameter to the function call.
-
+
+ You can have multiple cache files for a single call to display() or
+ fetch(). Let's say that a call to display('index.tpl') may have several
+ different output contents depending on some condition, and you want
+ separate caches for each one. You can do this by passing a cache_id as the
+ second parameter to the function call.
+ passing a cache_id to display()
@@ -24,35 +24,35 @@ $my_cache_id = $_GET['article_id'];
$smarty->display('index.tpl',$my_cache_id);
?>
]]>
-
+
-
- Above, we are passing the variable $my_cache_id to display() as the
- cache_id. For each unique value of $my_cache_id, a separate cache will be
- generated for index.tpl. In this example, "article_id" was passed in the
- URL and is used as the cache_id.
-
-
- Technical Note
-
- Be very cautious when passing values from a client (web browser) into
- Smarty (or any PHP application.) Although the above example of using the
- article_id from the URL looks handy, it could have bad consequences. The
- cache_id is used to create a directory on the file system, so if the user
- decided to pass an extremely large value for article_id, or write a script
- that sends random article_ids at a rapid pace, this could possibly cause
- problems at the server level. Be sure to sanitize any data passed in before
- using it. In this instance, maybe you know the article_id has a length of
- 10 characters and is made up of alpha-numerics only, and must be a valid
- article_id in the database. Check for this!
-
-
-
- Be sure to pass the same cache_id as the
- second parameter to is_cached() and
- clear_cache().
-
-
+
+ Above, we are passing the variable $my_cache_id to display() as the
+ cache_id. For each unique value of $my_cache_id, a separate cache will be
+ generated for index.tpl. In this example, "article_id" was passed in the
+ URL and is used as the cache_id.
+
+
+ Technical Note
+
+ Be very cautious when passing values from a client (web browser) into
+ Smarty (or any PHP application.) Although the above example of using the
+ article_id from the URL looks handy, it could have bad consequences. The
+ cache_id is used to create a directory on the file system, so if the user
+ decided to pass an extremely large value for article_id, or write a script
+ that sends random article_ids at a rapid pace, this could possibly cause
+ problems at the server level. Be sure to sanitize any data passed in before
+ using it. In this instance, maybe you know the article_id has a length of
+ 10 characters and is made up of alpha-numerics only, and must be a valid
+ article_id in the database. Check for this!
+
+
+
+ Be sure to pass the same cache_id as the
+ second parameter to is_cached() and
+ clear_cache().
+
+ passing a cache_id to is_cached()
caching = true;
$my_cache_id = $_GET['article_id'];
if(!$smarty->is_cached('index.tpl',$my_cache_id)) {
- // No cache available, do variable assignments here.
- $contents = get_database_contents();
- $smarty->assign($contents);
+ // No cache available, do variable assignments here.
+ $contents = get_database_contents();
+ $smarty->assign($contents);
}
$smarty->display('index.tpl',$my_cache_id);
?>
]]>
-
+
-
- You can clear all caches for a particular cache_id by passing null as the
- first parameter to clear_cache().
-
-
+
+ You can clear all caches for a particular cache_id by passing null as the
+ first parameter to clear_cache().
+
+ clearing all caches for a particular cache_id
clear_cache(null,"sports");
$smarty->display('index.tpl',"sports");
?>
]]>
-
+
-
- In this manner, you can "group" your caches together by giving them the
- same cache_id.
-
-
+
+ In this manner, you can "group" your caches together by giving them the
+ same cache_id.
+
+
+
+
\ No newline at end of file
+-->
diff --git a/docs/en/programmers/caching/caching-setting-up.xml b/docs/en/programmers/caching/caching-setting-up.xml
index eb9e2f31..ce288e8d 100644
--- a/docs/en/programmers/caching/caching-setting-up.xml
+++ b/docs/en/programmers/caching/caching-setting-up.xml
@@ -1,14 +1,14 @@
-
+ Setting Up Caching
- The first thing to do is enable caching. This is done by setting $caching = true (or 1.)
+ The first thing to do is enable caching. This is done by setting $caching = true (or 1.)
-
- enabling caching
-
+
+ enabling caching
+
caching = true;
$smarty->display('index.tpl');
?>
]]>
-
-
-
- With caching enabled, the function call to display('index.tpl') will render
- the template as usual, but also saves a copy of its output to a file (a
- cached copy) in the $cache_dir.
- Upon the next call to display('index.tpl'), the cached copy will be used
- instead of rendering the template again.
-
-
- Technical Note
-
- The files in the $cache_dir are named similar to the template name.
- Although they end in the ".php" extention, they are not really executable
- php scripts. Do not edit these files!
-
-
-
- Each cached page has a limited lifetime determined by $cache_lifetime. The default value
- is 3600 seconds, or 1 hour. After that time expires, the cache is
- regenerated. It is possible to give individual caches their own expiration
- time by setting $caching = 2. See the documentation on $cache_lifetime for details.
-
-
- setting cache_lifetime per cache
-
+
+
+
+ With caching enabled, the function call to display('index.tpl') will render
+ the template as usual, but also saves a copy of its output to a file (a
+ cached copy) in the $cache_dir.
+ Upon the next call to display('index.tpl'), the cached copy will be used
+ instead of rendering the template again.
+
+
+ Technical Note
+
+ The files in the $cache_dir are named similar to the template name.
+ Although they end in the ".php" extention, they are not really executable
+ php scripts. Do not edit these files!
+
+
+
+ Each cached page has a limited lifetime determined by $cache_lifetime. The default value
+ is 3600 seconds, or 1 hour. After that time expires, the cache is
+ regenerated. It is possible to give individual caches their own expiration
+ time by setting $caching = 2. See the documentation on $cache_lifetime for details.
+
+
+ setting cache_lifetime per cache
+
cache_lifetime = 30; // 30 seconds
$smarty->display('home.tpl');
?>
]]>
-
-
-
- If $compile_check is enabled,
- every template file and config file that is involved with the cache file is
- checked for modification. If any of the files have been modified since the
- cache was generated, the cache is immediately regenerated. This is a slight
- overhead so for optimum performance, leave $compile_check set to false.
-
-
- enabling $compile_check
-
+
+
+
+ If $compile_check is enabled,
+ every template file and config file that is involved with the cache file is
+ checked for modification. If any of the files have been modified since the
+ cache was generated, the cache is immediately regenerated. This is a slight
+ overhead so for optimum performance, leave $compile_check set to false.
+
+
+ enabling $compile_check
+
compile_check = true;
$smarty->display('index.tpl');
?>
]]>
-
-
-
- If $force_compile is enabled,
- the cache files will always be regenerated. This effectively turns off
- caching. $force_compile is usually for debugging purposes only, a more
- efficient way of disabling caching is to set $caching = false (or 0.)
-
-
- The is_cached() function
- can be used to test if a template has a valid cache or not. If you have a
- cached template that requires something like a database fetch, you can use
- this to skip that process.
-
-
- using is_cached()
-
+
+
+
+ If $force_compile is enabled,
+ the cache files will always be regenerated. This effectively turns off
+ caching. $force_compile is usually for debugging purposes only, a more
+ efficient way of disabling caching is to set $caching = false (or 0.)
+
+
+ The is_cached() function
+ can be used to test if a template has a valid cache or not. If you have a
+ cached template that requires something like a database fetch, you can use
+ this to skip that process.
+
+
+ using is_cached()
+
caching = true;
if(!$smarty->is_cached('index.tpl')) {
- // No cache available, do variable assignments here.
- $contents = get_database_contents();
- $smarty->assign($contents);
+ // No cache available, do variable assignments here.
+ $contents = get_database_contents();
+ $smarty->assign($contents);
}
$smarty->display('index.tpl');
?>
]]>
-
-
-
- You can keep parts of a page dynamic with the insert template function. Let's
- say the whole page can be cached except for a banner that is displayed down
- the right side of the page. By using an insert function for the banner, you
- can keep this element dynamic within the cached content. See the
- documentation on insert for
- details and examples.
-
-
- You can clear all the cache files with the clear_all_cache() function, or
- individual cache files (or groups) with the clear_cache() function.
-
-
- clearing the cache
-
+
+
+
+ You can keep parts of a page dynamic with the insert template function. Let's
+ say the whole page can be cached except for a banner that is displayed down
+ the right side of the page. By using an insert function for the banner, you
+ can keep this element dynamic within the cached content. See the
+ documentation on insert for
+ details and examples.
+
+
+ You can clear all the cache files with the clear_all_cache() function, or
+ individual cache files (or groups) with the clear_cache() function.
+
+
+ clearing the cache
+
clear_cache('index.tpl');
$smarty->display('index.tpl');
?>
]]>
-
-
-
+
+
+
+
+
\ No newline at end of file
+-->