Smarty and caching

Posted on 2006-05-04
Last Modified: 2013-12-12

Thought it was worth a shot here in case anyone has dealt with this so here we go..

I want to disable caching in Smarty.  I've read the manual and basically it says just set it to 0 or false.  Did it.  Didn't work.

I tried to clear the cache after a template reset, not clearing the cache.

Basically what needs to happen is that after a user resets to a new template, the results should show in the form of a new template.  What's happening is the cached Smarty template is showing the previous template.  It's annoying but I love Smarty so I dare not say anything bad about it.  I just want to figure this one out with some help from one of you = )

Question by:gijew
    LVL 2

    Expert Comment

    I think you can disable cashing for a template by adding this line (in the php code, not the template itself):

    $smarty->caching = false;

    LVL 2

    Author Comment

    I tried that.  I also tried setting it to 0 and tried clear_cache() and clear_cache_all()

    What finally ended up working (temp fix) was to set $force_compile to true.  That way it would just recompile the template each time.  Still, I know there's a better way to make this work.  I mean, there's gotta be = )
    LVL 7

    Accepted Solution

    smarty does not cache by default, it does compile though, templates are compiled only when the template file changes, you would of tunred caching on some for it to cache the contents, worth checking

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now