1

I hope you all are keeping safe during these uncertain times.

I have two questions.

I am creating a simple react-js page with 4 components. Can someone please guide me how the caching works in Headless mode ? As per the sitecore guidelines output caching saves the JSON that is returned by the Layout Service for each component. Does the guideline means caching will be handled by both layoutService and viewEngine?

Do I need to have Separate RedisCache server for headless mode architecture? I

1 Answer 1

2
  1. Sitecore JSS is using Sitecore MVC pipelines behind the scenes. So caching works the same way as in Sitecore MVC - the output of the rendering (in JSS case it is JSON) is cached in Sitecore's HTML cache (which can be configured per rendering/component). LayoutService indeed returns cached JSON per component.

    If by viewEngine you mean this https://jss.sitecore.com/docs/fundamentals/services/view-engine then it won't any add extra caching on top. It is used only in context of server-side rendering for Experience Editor.

  2. Question on whether it is worth implementing a distributed shared cache (such as Redis) is not really specific to JSS Headless mode as well. Would you implement a distributed shared cache if you would use Sitecore MVC? It highly depends on what you are doing in your renderings (accessing 3-rd party, doing extensive computations, etc.) or simply rendering output of a component datasource.

    There is one more place where you can add extra caching in headless architecture - the client side. Potentially, you can have some logic in your Node instance to cache output of LayoutService calls.

In any case I would not implement too much premature caching upfront and start with simply configuring Sitecore HTML cache for your components. And later on if you have any performance issues - add extra caching layers if needed.

4
  • Thank you so much Vitalii. It was very much informative. On the similar note when I make any changes in the layout service I need to run jss command to display on the webpage. It won't happen automatically. Is my understanding correct ? Commented Jun 3, 2020 at 9:36
  • If by "making changes in layoutservice" you mean updating content, then just hitting F5 in your browser will force your app to request LayoutService again, so no need to run any commands. Also, if you feel that my answer has solved the problem please mark it as accepted ;) Commented Jun 3, 2020 at 15:10
  • Thank you once again Vitalii but for some strange reason that's not happening and I am ending up executing commands to see the updated content :) Commented Jun 4, 2020 at 9:21
  • Hm, that is weird :) And which command do you execute? Commented Jun 5, 2020 at 11:41

Your Answer

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

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