<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>clear_cache()</title> <meta name="generator" content="DocBook XSL Stylesheets V1.75.1"> <link rel="home" href="index.html" title="Smarty Manual"> <link rel="up" href="api.functions.html" title="Chapter 13. Smarty Class Methods()"> <link rel="prev" href="api.clear.assign.html" title="clear_assign()"> <link rel="next" href="api.clear.compiled.tpl.html" title="clear_compiled_tpl()"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr><th colspan="3" align="center">clear_cache()</th></tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="api.clear.assign.html">Prev</a> </td> <th width="60%" align="center">Chapter 13. Smarty Class Methods()</th> <td width="20%" align="right"> <a accesskey="n" href="api.clear.compiled.tpl.html">Next</a> </td> </tr> </table> <hr> </div> <div class="refentry" title="clear_cache()"> <a name="api.clear.cache"></a><div class="titlepage"></div> <div class="refnamediv"> <h2>Name</h2> <p>clear_cache() — clears the cache for a specific template</p> </div> <div class="refsect1" title="Description"> <a name="id3098682"></a><h2>Description</h2> <code class="methodsynopsis"><span class="type">void </span><span class="methodname">clear_cache</span>(<span class="methodparam"><span class="type">string </span><span class="parameter">template</span></span>,<br> <span class="methodparam"><span class="type">string </span><span class="parameter">cache_id</span></span>,<br> <span class="methodparam"><span class="type">string </span><span class="parameter">compile_id</span></span>,<br> <span class="methodparam"><span class="type">int </span><span class="parameter">expire_time</span></span>);</code><div class="itemizedlist"><ul class="itemizedlist" type="disc"> <li class="listitem"><p> If you have <a class="link" href="caching.multiple.caches.html" title="Multiple Caches Per Page">multiple caches</a> for a template, you can clear a specific cache by supplying the <em class="parameter"><code>cache_id</code></em> as the second parameter. </p></li> <li class="listitem"><p> You can also pass a <a class="link" href="variable.compile.id.html" title="$compile_id"><em class="parameter"><code>$compile_id</code></em></a> as a third parameter. You can <a class="link" href="caching.groups.html" title="Cache Groups">group templates together</a> so they can be removed as a group, see the <a class="link" href="caching.html" title="Chapter 14. Caching">caching section</a> for more information. </p></li> <li class="listitem"><p> As an optional fourth parameter, you can supply a minimum age in seconds the cache file must be before it will get cleared. </p></li> </ul></div> <div class="example"> <a name="id3098814"></a><p class="title"><b>Example 13.8. clear_cache()</b></p> <div class="example-contents"><pre class="programlisting"> <?php // clear the cache for a template $smarty->clear_cache('index.tpl'); // clear the cache for a particular cache id in an multiple-cache template $smarty->clear_cache('index.tpl', 'MY_CACHE_ID'); ?> </pre></div> </div> <br class="example-break"><p> See also <a class="link" href="api.clear.all.cache.html" title="clear_all_cache()"><code class="varname">clear_all_cache()</code></a> and <a class="link" href="caching.html" title="Chapter 14. Caching"><code class="varname">caching</code></a> section. </p> </div> </div> <div class="navfooter"> <hr> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="api.clear.assign.html">Prev</a> </td> <td width="20%" align="center"><a accesskey="u" href="api.functions.html">Up</a></td> <td width="40%" align="right"> <a accesskey="n" href="api.clear.compiled.tpl.html">Next</a> </td> </tr> <tr> <td width="40%" align="left" valign="top">clear_assign() </td> <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td> <td width="40%" align="right" valign="top"> clear_compiled_tpl()</td> </tr> </table> </div> </body> </html>