Sitecore Personalization Rules Vs Caching

I recently ran into an issue with a personalization rule on a rendering that changed the data source for mobile devices, a common scenario if you want to reduce payload and improve mobile experience. However, I discovered if I hit a page with the component on a mobile device I was seeing the desktop version.

Using my SPE script to list component cache settings I discovered the component had “Vary By Data” enabled – could this be the problem? As it turns out it it was. You see Personalization rules enable dynamically changing of components and their data sources. However the “Vary By Data” option causes Sitecore to render cached html markup for the component without performing an actual rendering process. For the majority of scenarios applying personalization rules before retrieving output from cache would make caching almost pointless. But there are certain scenarios, like the one I described above, where this might be beneficial and improve performance. Thankfully, there is a solution using a custom “Vary By Personalized Data” covered here by Ahmed Okour.

It does feel like a gap in Sitecore’s implementation so you either Cache a component or you Personalize it. So this needs to be captured when defining requirements.

Is this component going to be personalized?

  • No – implement caching.
  • Yes – don’t implement caching.
  • Not sure – implement caching and disable it when the component needs to be personalized.
  • Need both – customize with Vary By Personalized Data.

Useful Info