Jump to:

22993 Posts in 11595 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » Partial Caching - Understanding the Concepts

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

Page: 1 2
Go to End
Author Topic: 4047 Views
  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Partial Caching - Understanding the Concepts Link to this post

    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.

  • ttyl
    Avatar
    Community Member
    114 Posts

    Re: Partial Caching - Understanding the Concepts Link to this post

    how can I tell if partial caching is working?

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: Partial Caching - Understanding the Concepts Link to this post

    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.

  • ttyl
    Avatar
    Community Member
    114 Posts

    Re: Partial Caching - Understanding the Concepts Link to this post

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

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: Partial Caching - Understanding the Concepts Link to this post

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

  • EzraNaj
    Avatar
    Community Member
    11 Posts

    Re: Partial Caching - Understanding the Concepts Link to this post

    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?

  • ttyl
    Avatar
    Community Member
    114 Posts

    Re: Partial Caching - Understanding the Concepts Link to this post

    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.

  • fiord
    Avatar
    Community Member
    79 Posts

    Re: Partial Caching - Understanding the Concepts Link to this post

    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 http://webspilka.com/mylogs/mysql.txt for page and refrash page

    4047 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.