When selecting a component's Cacheability, the Vary By options control the cache key. What happens if I cache a rendering but do not specify a Vary By option? Also- does Sitecore generate a different cache key depending on if the rendering has a datasource or not?
1 Answer
If you don't select Vary By Options, Then Sitecore will generate a cache key for the rendering that is unique per the context language, Which means the Html output in the cache will be the same for the same rendering on all pages within same language
If you select "Vary by Data" option and didn't set the datasource for rendering, Sitecore will use the Context Page Item ID (Plus context language) to generate the cache key, Which means the Html output in the cache will be the same on the same page on same language.
If you select "Vary by Data" option and you set the datasource for rendering, Sitecore will use the datasource item ID (Plus context language) to generate the cache key, Which means the Html output in the cache will be the same if the rendering is using the same datasource item within same language context.