HTMLキャッシュを有効にしたSXAサイト(JSONレイアウト)またはJSSサイトで起こりうるエラーについて


説明

本記事では、SXAサイトまたはSXAをベースにしたJSSサイトで、HTMLキャッシュが有効になっている場合にJSONデバイスを使用するとエラーが発生する、2つのシナリオについて説明します。

シナリオ1

SXAサイトがキャッシュを有効化したコンポーネントを持っている場合。
JSONデバイスを使用してフロントエンドでSXAサイトのページの再読み込みを実施すると、以下のエラーが発生する可能性があります:

Server Error in '/' Application.
Rendering data contained rendering reference ID e1354fcc-4fe0-4b4c-aa11-78b793895dfa but that rendering ID was not present in the rendered renderings context. This ought not to occur.
Description: An unhandled exception occurred.
Exception Details: System.InvalidOperationException: Rendering data contained rendering reference ID e1354fcc-4fe0-4b4c-aa11-78b793895dfa but that rendering ID was not present in the rendered renderings context. This ought not to occur.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Rendering data contained rendering reference ID e1354fcc-4fe0-4b4c-aa11-78b793895dfa but that rendering ID was not present in the rendered renderings context. This ought not to occur.]
Sitecore.LayoutService.ItemRendering.PlaceholderRenderingService.ConvertRenderedPlaceholderMarkup(RenderedPlaceholder placeholder, String contents, RenderedJsonRenderingContext renderedRenderingContext) +978
Sitecore.LayoutService.ItemRendering.PlaceholderRenderingService.RenderPlaceholder(PlaceholderDefinition placeholderDefinition, IRenderingConfiguration renderingConfiguration) +499
System.Linq.WhereSelectListIterator`2.MoveNext() +114 System.Linq.WhereEnumerableIterator`1.MoveNext() +236
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +436
System.Linq.Enumerable.ToList(IEnumerable`1 source) +70
Sitecore.LayoutService.ItemRendering.LayoutService.Render(Item item, IRenderingConfiguration renderingConfiguration, RenderOptions renderOptions) +838
Sitecore.XA.Feature.LayoutServices.Integration.Repositories.PageLayoutJsonRepository.GetJson(Item item) +280
Sitecore.XA.Feature.LayoutServices.Integration.Repositories.PageLayoutJsonRepository.GetModel() +93
Sitecore.XA.Foundation.Mvc.Controllers.StandardController.Index() +144 lambda_method(Closure , ControllerBase , Object[] ) +90
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +229
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +80
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +454
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +454
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +524

シナリオ2

SXA PowerShellスクリプトで作成したJSSサイトがキャッシュを有効化したコンポーネントを持っている場合。
JSONデバイスを使用してフロントエンドでサイトの再読み込みを実施すると、以下のエラーが発生する可能性があります:

Rendering data contained rendering reference ID 12b32f25-1d0d-4201-be46-675dcee4fefb but that rendering ID was not present in the rendered renderings context. This ought not to occur.
[InvalidOperationException: Rendering data contained rendering reference ID 12b32f25-1d0d-4201-be46-675dcee4fefb but that rendering ID was not present in the rendered renderings context. This ought not to occur.]
Sitecore.LayoutService.ItemRendering.PlaceholderRenderingService.ConvertRenderedPlaceholderMarkup(RenderedPlaceholder placeholder, String contents, RenderedJsonRenderingContext renderedRenderingContext) +1016
Sitecore.LayoutService.ItemRendering.PlaceholderRenderingService.RenderPlaceholder(PlaceholderDefinition placeholderDefinition, IRenderingConfiguration renderingConfiguration) +499
System.Linq.WhereSelectListIterator`2.MoveNext() +117
System.Linq.WhereEnumerableIterator`1.MoveNext() +127
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +453
System.Linq.Enumerable.ToList(IEnumerable`1 source) +69
Sitecore.LayoutService.ItemRendering.LayoutService.Render(Item item, IRenderingConfiguration renderingConfiguration, RenderOptions renderOptions) +1089
Sitecore.JavaScriptServices.ViewEngine.Presentation.JsLayoutRenderer.ResolveFunctionArgs() +73
Sitecore.JavaScriptServices.ViewEngine.Presentation.JssRenderer.Render(TextWriter writer) +201
Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +147
Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +74
(Object , Object ) +14
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +490
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +236
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +195
Sitecore.Mvc.Presentation.RenderingView.Render(ViewContext viewContext, TextWriter writer) +297
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +91
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
System.Web.Mvc.Async.<>c__DisplayClass3_1.b__1(IAsyncResult asyncResult) +39

解決策

この問題を解決するには、以下のオプションのいずれかを検討してください: