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 issue with LastEdited


5 Posts   348 Views


25 June 2013 at 1:37am (Last edited: 25 June 2013 1:38am), Community Member, 90 Posts


inside the SS template i got

<% cached Children.max(LastEdited) %>
<% loop Children %>
<% end_loop %>
<% end_cached %>

Each sub page got a thumb-nail image attached. In CMS, if i change the thumb-nail image via the UploadField, click 'Save and Publish', the 'LastEdited' field doesn't change (probably because i did not change the content of it?) and thus the change is not reviewed on the front pages. Is this a SS bug that the field 'LastEdited' not changed even though i click on the 'Save and Publish" ?

How to get around this partial caching problem?


25 June 2013 at 3:50am Community Member, 146 Posts

One solution is to subclass Image, then your page can have a relation to that class instead of a relation to image. So:

class MyImage extends Image {

class MyPage extends Page {
public static $has_one = array(

Then in your template, you can do <% cached Children.Max(LastEdited), List(MyImage).Max(LastEdited) %>

Hope this helps


25 June 2013 at 4:35am Community Member, 90 Posts

I guess List(MyImage).Max(LastEdited) will force SS to search all 'MyImage' objects in database and get the lastest LastEdited field value as part of the cache key.

The problem is: MyPage and MyImage is a many-many relation. The LastEdited field will not work because the image itself is not edited. the image is linked to another page. we just built a new link.

I guess I have to write a function to find out all the related images of the sub page and work out a key, and pass that function to SS template

class MySubPage {
static $many_many = array('Images' =>'MyImage')



25 June 2013 at 8:10pm Community Member, 146 Posts

Yep, you can calculate the cache key in your controller:

I don't really know the best way to approach it, though. Perhaps you could fetch all records from the join table (e.g 'MyImage_MySubPage'), implode it to a string and md5 hash it?


25 June 2013 at 9:28pm Community Member, 90 Posts

That's what i thought, but then how do you 'aggregate' all the md5 strings? using max,min,avg, or sum is not going to work. I think I just concatenate all the md5 string together to build a large key.