I have a couple of controller renderings where the data loaded is from several Sitecore items including the "page" itself, and the Rendering datasource is not actually set on the Rendering. How can I cache this so that the rendering is cached differently for each page it's on despite no datasource on the rendering being set? I would think Vary By Data, but doesn't that only work if you have different datasources set on the individual renderings?
-
Can you try to add also the vary by param and see if it works? So, check the cacheable, vary by data and vary by param – Hishaam Namooya Sep 5 '19 at 21:36
-
1No rendering should be implemented like this – Mark Cassidy♦ Sep 5 '19 at 23:03
As long as the output is always the same on each page then you can use Vary By Data
, this will cache based on the context item if no data source is set.
Note that as per Mark's point this might not be the best way to implement a rendering as you will lose the ability to personalize the rendering through the Datasource
.