21286 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 297 Views |
-
Partial Caching

15 May 2012 at 4:29pm Last edited: 15 May 2012 5:03pm
I am using partial caching for the main content block of main template.
This is what I have in the template file
<% cached 'database', LastEdited %>
$Content
<% end_cached %>The main template is used on most of the page.
If I visit "about us" it will display the content for about us, then when I visit "Services" it will display the content from the "about us" page
It's cached the content from "About Us" and displaying the "About Us" content on all of the pages sharing the same template.
How do I get this to work properly so it displays the content of it's own page
Thanks
-
Re: Partial Caching

20 May 2012 at 12:46am
Hi VXD,
Try adding 'URLSegment' to the cache key. Ie.
<% cached 'database', LastEdited, URLSegment %>
$Content
<% end_cached %>There is an explanation of this in the article on SilverStripe by Phillip Krenn.
Hope this helps.
VWD.
-
Re: Partial Caching

20 May 2012 at 11:43am
ID might be a safer key than URLSegment as you'll have multiple pages with the same URLSegment (nested urls).
-
Re: Partial Caching

21 May 2012 at 7:23am
Hi Will,
Thanks for that suggestion - so $URLSegment is not unique across a site, and obviously $ID is.
Kind regards,
Prem. -
Re: Partial Caching

12 June 2012 at 12:19am
Thanks for that, so it should be
<% cached 'database', LastEdited, ID %>
$Content
<% end_cached %>
| 297 Views | ||
|
Page:
1
|
Go to Top |



