Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Partial Caching - Understanding the Concepts

Go to End

19 Posts   6333 Views


Forum Moderator, 5523 Posts

20 September 2010 at 7:45pm

And the question: if i add <% cached LastEdited %> $Layout <% end_cached %> to why StaffPage isn't update when i change StaffItem?

Because it could be that you have cached the block with the last edited date. The nested cacheblocks could have involved some additional caching you don't need. Rather than using a custom cache key could you perhaps experiment with something like

<% cached 'staffitem', Aggregate(StaffItem).Max(LastEdited) %>

You may also want to try and remove the Parent LastEdited Cache (or use <% uncached %> around the middle cache). According to the docs nested caching should work fine but I'm not sure what to look into when it fails.


Community Member, 114 Posts

21 September 2010 at 4:06am

how can I tell if partial caching is working?


Community Member, 271 Posts

21 September 2010 at 4:18am

If you see some zend_cache files in the silverstripe-cache/cache folder.
And when you edit content and don't see the changes immediately on the frontend site, unless you use <% cached LastEdited %>, then the cache should be refreshed.

Another way is to add ?debug_profile=1 to your url and see the differences in compiling time with and without the partial caching. When using large DataObjectSets, this will difference can be quite huge.


Community Member, 114 Posts

21 September 2010 at 4:30am

I don't have a cache folder at there a config setting I'm missing?


Community Member, 791 Posts

21 September 2010 at 6:11am

create a silverstripe-cache directory (writable) in your webroot , SS will use it.


Community Member, 11 Posts

21 September 2010 at 8:14pm

Is it advisable to apply partial caching on a portion of page generated by ajax?
I have a portion on a page containing multiple tabs. Content of each tab changes when a different tab is clicked. This
is ajax driven.
I tried applying partial caching and experimented with it. It just didn't work and content of the tabs sometimes changes, sometimes they don't.

Should I just remove the partial caching from it?


Community Member, 114 Posts

22 September 2010 at 1:23am

FWIW, for the project I'm working on now I think the best bet for me is staticpublisher for the majority of pages and using partial caching on a few pages that that won't work for.


Community Member, 89 Posts

15 May 2011 at 2:28am

Edited: 15/05/2011 2:51am

why after adding Partial Caching mysql queries executed again?
what am I doing wrong?

in my template I add next code

<% cached 'page', LastEdited, CacheSegment %><!DOCTYPE html>
<html lang="$ContentLocale">
</html><% end_cached %>

In mysite/code/Page.php I add a new method in the Controller:

protected function CacheSegment(){

in config.php I have next code

//	'localhost',
//	''

I try chande my template to

<% cached %><!DOCTYPE html>
<html lang="$ContentLocale">
</html><% end_cached %>

, but the situation does not change. Queries to the database will still go, though always showing cached pages

why in my mysql.log I have mo 20 mysql query for load page, and if I refresh page I also have mo 20 mysql query

my mysql.log for page and refrash page