21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 376 Views |
-
Partial caching doesn't re-cache on template change.

18 May 2012 at 9:33am Last edited: 18 May 2012 3:40pm
Hi,
I've implemented partial caching on a site, and I'm noticing significant performance gains already.
I notice however that when the template within the partial cache block is changed the cache doesn't refresh as the documentation says it should. The only thing that causes a refresh is when the explicitly provided key changes.
Eg.
<% cached 'MyCachedBlock', SiteConfig.LastEdited %>
<div>
$SiteConfig.tagline
<div>
<% end_cached %>Whenever I change the template within the partial cache block, the cache doesn't refresh,. It only refreshes when I modify SiteConfig. Even a ?flush=all has no effect
This happens for all page templates as well as module templates. Interestingly, in cache blocks which don't have an explicit key, a ?flush=all does refresh the cache.
Anyone else seen this?
Kind regards,
VWD. -
Re: Partial caching doesn't re-cache on template change.

18 May 2012 at 4:03pm
A bit more on this... whilst the partial caching still doesn't re-cache on a template change, it does when I perform a ?flush=all now.
I realised that the cache block was nested within another with the same key...
<% cached 'OuterCachedBlock', SiteConfig.LastEdited %>
<div id="$UniqueID">
<% cached 'MyCachedBlock', SiteConfig.LastEdited %>
<div id="inner-$UniqueID">
$SiteConfig.tagline
</div>
<% end_cached %>
</div>
<% end_cached %>When I modify the code to uncache around the nested block, SS recaches on a ?flush=all but still not on a template change.
Eg.
<% cached 'OuterCachedBlock', SiteConfig.LastEdited %>
<div>
<h3>$SiteConfig.PhoneNumber</h3>
<% uncached %>
<div id="$UniqueID">
<% cached 'MyCachedBlock', SiteConfig.LastEdited %>
<div id="inner-$UniqueID">
$SiteConfig.tagline
</div>
<% end_cached %>
</div>
<% end_uncached %>
</div>
<% end_cached %>Any ideas?
Thank you.
VWD. -
Re: Partial caching doesn't re-cache on template change.

20 May 2012 at 12:00pm Last edited: 20 May 2012 12:01pm
I get around this by including this in my _config.php
if(isset($_REQUEST['flush'])) {
SS_Cache::set_cache_lifetime('any', -1, 100);
}Whether you are using partial caching or not, you always need to flush if you make template changes.
-
Re: Partial caching doesn't re-cache on template change.

21 May 2012 at 11:31am
Thanks Will.
So does that mean the section "Cache blocks and template changes" in the documentation is inaccurate? Or do I read incorrectly?
How does including the statement...
if(isset($_REQUEST['flush'])) {
SS_Cache::set_cache_lifetime('any', -1, 100);
}... differ in behaviour from the normal explicit cache flushing functionality?
Thanks Will.
VWD.
| 376 Views | ||
|
Page:
1
|
Go to Top |


