Re: [SMARTY-DEV] Caching problem
| From: | boots | Date: | Tue, 02 Aug 2005 19:17:23 +0000 |
| Subject: | Re: [SMARTY-DEV] Caching problem | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2750@lists.php.net to get a copy of this message | ||
Smarty has two separate features, caching and compiling. Each generate
files but only caching can be turned off.
http://smarty.incutio.com/?page=CacheAndCompile
--- Alain Williams <addw@phcomp.co.uk> wrote:
> I have a caching problem.
>
> Code:
> $tpl =& new Smarty;
> $tpl->template_dir = '.'; // Where the template files live
> // Smarty 'compiles' the .tpl and creates a .php script to generate
> the html
> // Next time smarty will use the .php without recompilation if the
> .tpl has not changed
> $tpl->compile_dir = 'cache';
> $tpl->caching = 1;
> $tpl->cache_lifetime = 86400; // Regenerate cache once/day
>
> ....
>
> // parse and display the template
> $tpl->display('QfSmarty.tpl');
>
> In cache/ this generates
>
> -rw-r--r-- 1 apache apache 4257 Aug 2 19:36
> %%E0^E08^E08C3785%%QfSmarty.tpl
> -rw-r--r-- 1 apache apache 4130 Aug 2 19:36
> %%E0^E08^E08C3785%%QfSmarty.tpl.php
>
> The generated .php file is fine and if run again (eg if I just remove
> *.tpl),
> but the .tpl file has everything substituted in ... it is html (with
> some junk
> at the top).
>
> The trouble is that next time it is run the php will generate
> different output
> (which the compiled .php will correctly generate) - but the compiled
> php will not
> be looked at because there exists a .tpl. What I want is the ability
> to say:
>
> Please cache the .php, but don't cache the .tpl
>
> Is there a way of asking this that I have overlooked ?
>
> TIA
>
> --
> Alain Williams
> Parliament Hill Computers Ltd.
> Linux Consultant - Mail systems, Web sites, Networking, Programmer,
> IT Lecturer.
> +44 (0) 787 668 0256 http://www.phcomp.co.uk/
>
> #include <std_disclaimer.h>
>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs