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, biapar, Willr, Ingo, swaiba, simon_w

Partial Caching - Understanding the Concepts


Reply

16 Posts   4373 Views

Avatar
Willr

20 September 2010 at 7:45pm Forum Moderator, 5511 Posts

And the question: if i add <% cached LastEdited %> $Layout <% end_cached %> to Page.ss 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.

Avatar
ttyl

21 September 2010 at 4:06am Community Member, 114 Posts

how can I tell if partial caching is working?

Avatar
Martijn

21 September 2010 at 4:18am Community Member, 271 Posts

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.

Avatar
ttyl

21 September 2010 at 4:30am Community Member, 114 Posts

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

Avatar
Fuzz10

21 September 2010 at 6:11am Community Member, 787 Posts

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

Avatar
EzraNaj

21 September 2010 at 8:14pm Community Member, 11 Posts

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?

Avatar
ttyl

22 September 2010 at 1:23am Community Member, 114 Posts

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.

Avatar
fiord

15 May 2011 at 2:28am (Last edited: 15 May 2011 2:51am), Community Member, 79 Posts

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

in my template Page.ss I add next code

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

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

protected function CacheSegment(){
return $_SERVER["REQUEST_URI"];
}

in config.php I have next code

//Director::set_dev_servers(array(
//   'localhost',
//   '127.0.0.1'
//));
//Director::set_environment_type('dev');

I try chande my template to

<% cached %><!DOCTYPE html>
<html lang="$ContentLocale">
<head>
...
...
</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 [url]http://webspilka.com/mylogs/mysql.txt[/url] for page and refrash page