2

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?

2
  • 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 Sep 5, 2019 at 21:36
  • 1
    No rendering should be implemented like this Sep 5, 2019 at 23:03

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.