Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Output caching

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

Page: 1
Go to End
Author Topic: 1631 Views
  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Output caching Link to this post

    We are experiencing some performance issues on a fairly large Silverstripe site and I'm trying to 'fix' it by using APC (a PHP cacher).

    Situation :
    - We have quite some dynamic pages (logins etc.) , so can't use the static exporter.
    - I've tried to store collections of Silverstripe objects (mainly DataObjectSets) in APC , but trying to get them to serialize and unserialize turned out to be a b*tch.
    - Storing parts of pages is hard, since I don't really know where to start .... It would be great to tie a caching mechanism into the Silverstripe template system itself ....

    Did anyone succeed in doing something like this ?

    Pointers / ideas are of course also welcome. ;-)

    Cheers.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Output caching Link to this post

    AFAIK, you can limit StaticPublisher to certain pages, and serve others dynamically. This of course assumes you don't have dynamic parts like a "logged in as" on all pages. What problems did you have with caching DataObjects? Did they not properly "re-hydrate"?
    Caching on a template level would probably be the best "bang for your buck", but is also the hardest to invalidate, which is why SilverStripe has traditionally stayed away from this. Thats not to say its impossible though... Sorry can't help more at the moment, let us know how you get on!

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Output caching Link to this post

    Thanks for your reply.

    > This of course assumes you don't have dynamic parts like a "logged in as" on all pages.

    Indeed, we do have a "login" part on each and every page. No go for the static publisher.

    > What problems did you have with caching DataObjects? Did they not properly "re-hydrate"?

    Yup. Did not find a working method to serialize and deserialize them ....

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Output caching Link to this post

    Hi
    Did you get any further with this?

    As for template caching, would that be something like <% cache %> cache this <% end_cache %>? That would be a totally different system from the static publisher...

    Just wondering what percentage of time goes into the actual rendering of the template? So how much would, say, caching an entire page except for a simple form reduce loading time?

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Output caching Link to this post

    Nope. I ended up creating some very nasty hacks that involved generating and outputting HTML in my controller classes so I could properly cache them.... Hehe...

    The rendering of the template isn't that big of a deal. I just want to prevent running the controller code if not needed (ergo , when a cached version exists).

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Output caching Link to this post

    >> I ended up creating some very nasty hacks...
    I would be interested I have my share of slooowhosts

    I've not gone much farther yet then having my static forms php-validate dynamically, by adding some thingy to the url...

    [EDIT] But nah... I guess adding HTML from the controller is something of a last resort. Does it really make much of a difference though? As in time?

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Output caching Link to this post

    >> [EDIT] But nah... I guess adding HTML from the controller is something of a last resort.

    Trust me , it was. ;-)

    >>Does it really make much of a difference though? As in time?

    Well, the site I was trying to speed up contains a LOT of custom work (pulling data from different webservices etc. etc.) that involved a lot of (expensive) casting to and from silverstripe data-objects (in order to use them "nicely" in the template)... So yes, caching the HTML shaved off a lot of processing time! ;)

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Output caching Link to this post

    Still there's something to say for extending static publishing. For instance - I had this site that had a 'static sidebar' - some data that appear throughout the site, but would often be changed by the client (like adding an extra link or so) In this case it was an extra ssbits-style sidebar that was in fact a page in the CMS. Problem: whenever the sidebar is changed, all static pages on the site have to be updated - something you don't really want.

    It would be great to have a way you could dynamically combine two or more static files - just thinking out loud: one way would be have HTML generated differently for the StaticPublisher by acknowledging a special command in the template that tells the templating engine to replace a certain block of code by an include statement. Maybe by just calling the page in a /dev/static/ kind of way from the publisher? So now you'd have a somewhat less static' file with an include to another static file? This file could then be interpreted by a script that combines the lot.

    You could even have the script simply replace a block of html based on a comment in the template and leave out the StaticPublisher changes for now. I'm a bit worried about security though...

    And of course, as you're importing all kinds of dynamic external content, this has no use whatsoever... But still...

    1631 Views
Page: 1
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.