|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
cyber Smarty Regular
Joined: 08 Jun 2006 Posts: 51
|
Posted: Wed Jul 29, 2015 8:56 am Post subject: loadFilter('output','trimwhitespace') and isCached() |
|
|
I want to try loadFilter('output','trimwhitespace') ( http://www.smarty.net/docs/en/api.load.filter.tpl ) but since I use caching as well I wonder how the two work together ?
I would like to call loadFilter('output','trimwhitespace') every time, no matter if the page is cached or not (yet).
At what stage is this filter executed exactly ?
Is it also executed on a cached page ?
Is it executed before caching, and hence the cached content is 'trimmed'
I just want to avoid executing the filter when it's not needed |
|
Back to top |
|
cyber Smarty Regular
Joined: 08 Jun 2006 Posts: 51
|
Posted: Thu Jul 30, 2015 2:32 pm Post subject: |
|
|
Looking at the cached files, the filter appears to have been applied.
Does this mean it won't be executed again on cached content ? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Aug 03, 2015 6:05 pm Post subject: |
|
|
When caching is enabled it does depend if your template does contain nocache sections or not.
In the best case the output filter runs once before the cache file is saved.
If your template contains nocache sections this is not possible as the output filter must run also over the not cached content. In this case the filter runs before the content is being sent to browser same way as when caching is disabled.
The same is true when you {include} a subtemplate which has its own caching parameter. The output filter will run each time before content is sent to browser. |
|
Back to top |
|
cyber Smarty Regular
Joined: 08 Jun 2006 Posts: 51
|
Posted: Mon Aug 03, 2015 6:16 pm Post subject: |
|
|
Thanks !!
I don't use {nocache} sections (yet, so good to know !)
But in any event, if I understand correctly, the output filter will run only once ?
- Either before the cache is written to HD (and then not again on display)
- Or just before the data is displayed (but then the cache has not been saved using the filter already) ?
Good to know the cache can already be 'filtered' this way and good to know that the filter is not executed twice in some cases (on the cache and on during display) |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Aug 03, 2015 7:28 pm Post subject: |
|
|
The content sent to the browser will run in any case just once through the output filter.
Smarty does detect automatically if the filter can run before the cache file is being saved. If this is the case the cached page will be send directly to the browser. |
|
Back to top |
|
cyber Smarty Regular
Joined: 08 Jun 2006 Posts: 51
|
Posted: Tue Aug 04, 2015 5:56 am Post subject: |
|
|
Perfect !
This is all I need to know.
Cheers |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|