Skip to main content

Command Palette

Search for a command to run...

Sitecore XM Cloud: Snapshot Publishing Vs Edge runtime Publishing

Updated
4 min read

Introduction

Publishing in XM Cloud works differently compared to XP/XM. For items with layouts, a JSON representation is generated, and the structure of this JSON varies depending on the type of publishing selected.

Snapshot publishing (v1) - stores the JSON as a single entity on Experience Edge.

Edge runtime publishing (v2) - stores the main structure layout, with separate references to each data source. The layout is assembled at delivery time (runtime) instead of publishing time. If there are any Integrated Queries even those are executed at Runtime

In Snapshot Publishing, whenever a datasource is updated, the entire page needs to be republished because a new layout JSON must be generated.

If the change happens in a global datasource (for example, the header), then all pages need to be republished — which is similar to doing a full site publish. This is why Sitecore recommends not including global data in the Layout Service output. Instead, Sitecore suggests fetching global data through a GraphQL call from the rendering host.

Additionally, integrated GraphQL queries are executed during publishing, they can further increase the publishing time.

To address these issues, Sitecore offers an option to opt in to Edge Runtime Publishing. In this approach, changes in a datasource do not trigger page publishing. Instead, the layout is assembled at delivery time (runtime) rather than at publishing time. This significantly improves publishing speed, but comes with a trade-off: the initial page delivery may be slightly slower.

Decision Guide

ParameterSnapshot PublishingEdge Runtime PublishingNotes / Impact
Publishing SpeedNot preferred, but can be considered if global datasources are fetched via GraphQL queries from the rendering host and if there are no integrated graphql queries.PreferredIn edge runtime Publishing dependant pages are not published and Integrated graphql queries are Not Executed during publish time which improves the publishing speed
Initial Page LoadPreferredNot Preferred, can be considered if ISR is implementedIn Edge Runtime, pages are assembled at runtime, and any integrated GraphQL queries are executed on the fly. This means the first page load after a cache clear can be slower. However, if Incremental Static Regeneration (ISR) is implemented, this impact can be minimised or even eliminated.
Capability to publish only Specific Sections of a pageNot Preferred, Can be considered if workflows are implemented and there are no shared fieldsPreferredIn Snapshot publishing the complete json is regenerated which can update other sections of the page
Large Layout SizePreferredNot PreferredIn Edge runtime publishing there is threshold set for the layout size, publishing fails if size is more than the specified threshold
Content Freshness of Integrated Graphql Query ResponseNot Prefered. Calculated at publish time. Only refreshed after a republish of the pagePreferredIn Edge runtime publishing integrated graphql response is fetched at runtime and therefore rendered correctly
Content ResolversSupportedSupported with Configuration changesIn edge runtime publishing an additional configuration change is required to ensure accuracy
Additional publishingIf you use a local datasource, the page is not treated as a dependency, so the page item must be published explicitlyif a datasource item has dependencies. for any change in dependency(eg child items) the datasource must be published explicitlyIn Snapshot publishing if datasource changes are not reflected on the page we would need to explictly publish. In Edge runtime publishing we would need to publish the actual datasource items for any datasource dependency changes

How to Enable Edge Runtime Publishing

  • In the Deploy app, create an environment variable:
    Sitecore_ExperienceEdge_dot_WorkerStoreEnabled and set it to true

  • Restart the environment

  • Republish All the Sites

How to Revert Back to Snapshot Publishing

  • In the Deploy app, create an environment variable:
    Sitecore_ExperienceEdge_dot_WorkerStoreEnabled and set it to false

  • Restart the environment

  • Delete Edge Content

  • Republish All the Sites

Conclusion

In conclusion, the choice between Snapshot Publishing and Edge Runtime Publishing in XM Cloud depends on various factors such as publishing speed, initial page load time, and content freshness. Snapshot Publishing is suitable for scenarios where global datasources are fetched via GraphQL queries, and large layout sizes are involved. However, it requires republishing the entire page for any datasource updates. On the other hand, Edge Runtime Publishing offers improved publishing speed and content freshness by assembling layouts at runtime, making it ideal for dynamic content scenarios. It is important to weigh the trade-offs, such as the potential for slower initial page loads, and consider implementing strategies like Incremental Static Regeneration (ISR) to mitigate these effects. Ultimately, the decision should align with the specific needs and priorities of your project.

More from this blog

Sitecore Pulse

15 posts