Smarty and caching

Posted on 2006-05-04
Medium Priority
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

Expert Comment

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

$smarty->caching = false;


Author Comment

ID: 16616160
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 = )

Accepted Solution

JB04 earned 2000 total points
ID: 16623238
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 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