Replies: 17 comments 18 replies
-
@AnrDaemon @glensc @uwetews @dusta @thirsch @JonisoftGermany @xorti @ssigwart @IT-Experte @Hunman @mohrt @scottchiefbaker @mreiche love to hear your thoughts on this matter |
Beta Was this translation helpful? Give feedback.
-
I don't remember ever having problems with cached results from functions. Dynamic variables I usually put in php. This can be used e.g. to save some rand() function in template.
useful thing with CloudFlare |
Beta Was this translation helpful? Give feedback.
-
I've just grepped through all of our templates and we are not using it. Also, I wasn't aware it exists. Nevertheless, it sounds good to me to have the {cache}-Tag and there are some cases this might be useful for us as well. |
Beta Was this translation helpful? Give feedback.
-
We use a custom {cache name=xx} tag aswell. Tried to incorporate the {nocache} tag but it's much less intuitive when you're working with a lot of dynamic templates. It's much easier to {cache} the resource intensive parts. |
Beta Was this translation helpful? Give feedback.
-
I use Smarty in multiple projects and don't use |
Beta Was this translation helpful? Give feedback.
-
We don't use the cache system withr WIKINDX. For other project at work I have not used the cache feature. It is very reasonable to provide only one of the two primitives and preferably the one that is has a positive and explicit meaning. {cache}{/cache} receives my favor if I had to use it because I don't see why caching an entire template. |
Beta Was this translation helpful? Give feedback.
-
I have never used I have no strong feelings about |
Beta Was this translation helpful? Give feedback.
-
I’m ok to axe it. It a seldom used feature that lends to bad habits imho.
…On Fri, Jan 27, 2023 at 5:42 PM Scott Baker ***@***.***> wrote:
I have never used nocache... in fact I learned that nocache was a thing
when this discussion opened up.
I have no strong feelings about nocache.
—
Reply to this email directly, view it on GitHub
<#853 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHZCLBRAO2V4LRDXK2ZFDLWURMNHANCNFSM6AAAAAAUIUPUYU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
We use Smarty caching a lot at TechPowerUp, but never with nocache, just grepped my sources. We do use clearCache() though |
Beta Was this translation helpful? Give feedback.
-
In all projects so far, I disabled caching at all and made sure, caching lifetime is set to zero. More than 90 percent of content is dynamic. It is not suitable to disable caching at each template or loop or to set nocaching for every single assigned variable. Because of general disabling cache, there was no need to use nocache-tag, nor nocache attribute at loops nor defining assigning variables as nocache. I would like to know if others also chose this way. I was and am responsible for many different projects using Smarty, which have hundreds of templates. You really need to dig deep to find content, which is NOT dynamic. But who uses Smarty for static websites? |
Beta Was this translation helpful? Give feedback.
-
I used Smarty for years in big projects with many templates and a lot of custom extensions. We were also using the caching feature by default, to reduce load in heavy used environments. We were only using This was an architectural decision, because the caching feature was kind of a USP of Smarty for us. But this feature also had a bug, which I fixed in my personal fork, because the core developer team never accepted #407 as a bug. |
Beta Was this translation helpful? Give feedback.
-
I use nocache only one time. {nocache}{if $smarty.server.REQUEST_URI eq '/'}<script>var xxx=123;</script>{/if}{/nocache} I think I can change to a attribute nocache. {if $smarty.server.REQUEST_URI eq '/' nocache}<script>var xxx=123;</script>{/if} |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
Bad habits or not, the caching feature was one of the primary reasons for Smarty to exist. TL;DR: Remove |
Beta Was this translation helpful? Give feedback.
-
I have it in some code, but it's vestigial at this point because browser form autocompletion made loading from cookies/session data obsolete. |
Beta Was this translation helpful? Give feedback.
-
For the record, the Tiki project uses Smarty since 2002 (https://doc.tiki.org/Smarty-Templates) but doesn't use nocache. |
Beta Was this translation helpful? Give feedback.
-
Why not have {cache} abc {/cache} . |
Beta Was this translation helpful? Give feedback.
-
While rewriting Smarty for v5 I stumbled upon the various ways Smarty supports cache busting through:
{nocache}...{/nocache}
block{yourtaghere nocache}
tag option available for most template functions$tpl->assign('name', 'Bob', true)
or{assign var="name" value="Bob" nocache}
See: https://smarty-php.github.io/smarty/programmers/caching/caching-cacheable.html
These features enable you to activate output caching on your Smarty templates, but nevertheless keep certain parts dynamic. The resulting cache file is a mix of static output and dynamic PHP code.
The logic required to make this work is very complex. It slows down the caches (obviously) but it also places extra burdens on the developer implementing them. For example:
At iWink, we've never used these features. We do have a custom
{cache}...{/cache}
block though, which does exactly the opposite. It allows you to cache certain parts of an otherwise dynamic template, storing the output in memcache instead of file based caches for example. By specifying a cache key, you can control when your caches will invalidate.I am in favor of removing the nocache-functionality from Smarty and adding the
{cache}...{/cache}
block as a substitute for the occasions where you might benefit from caching parts of a template. But before doing so, I figured it would make sense to poll if others are depending on this.So please answer this poll and if you using this functionality please share how and why.
27 votes ·
Beta Was this translation helpful? Give feedback.
All reactions