I have started a new site in version 3.1.13 and am struggling to understand why my partial caching is not working.
In a previous silverstripe version (3.0) it used to save cache files in the /silverstripe-cache/cache with file names such as zend_cache----cacheblockXXXXX but now in v 3.1.13 it seems to create user named folders and doesn't seem to be generating the zend_cache----cacheblock files in any of the subfolders.
I have created the following function in page.php where BlogArticle is a dataobject
public function LatestBlogArticles($limit = 3){
$b = DataObject::get('BlogArticle', '', '', '', $limit);
return $b;
}
On my HomePage.ss I have the following:
<ul class="blog-posts">
<% cached "latestblogarticles", $List("BlogArticle").count() %>
<% loop LatestBlogArticles %>
<li>
$Title
<datetime>$Date.format(F d, Y)</datetime>
</li>
<% end_loop %>
<% end_cached %>
</ul>
Running ?showqueries=1 shows the following queries
...
SHOW TABLES LIKE 'BlogArticle' 0.0008s
SHOW FULL FIELDS IN "BlogArticle" 0.0024s
SELECT DISTINCT "ClassName" FROM "BlogArticle" 0.0004s
SELECT DISTINCT count(DISTINCT "BlogArticle"."ID") AS "0" FROM "BlogArticle" 0.0004s
SELECT DISTINCT "BlogArticle"."ClassName", "BlogArticle"."Created", "BlogArticle"."LastEdited", "BlogArticle"."Title", "BlogArticle"."Abstract", "BlogArticle"."Content", "BlogArticle"."URLSegment", "BlogArticle"."Date", "BlogArticle"."MetaTitle", "BlogArticle"."MetaDesc", "BlogArticle"."Active", "BlogArticle"."ArticleImageID", "BlogArticle"."ID", CASE WHEN "BlogArticle"."ClassName" IS NOT NULL THEN "BlogArticle"."ClassName" ELSE 'BlogArticle' END AS "RecordClassName" FROM "BlogArticle" LIMIT 3 0.0043s
...
You would expect with caching if you refresh the page only the SELECT DISTINCT count(DISTINCT "BlogArticle"."ID") query would execute as the number of BlogArticles has not changed. But that is not the case, the above queries are still running and I see no generated cache files.
Can anyone please help me on how caching should work in this example? The documentation is not very helpful for beginners!
Thanks