Response Orchestration

Response Orchestration, also known as Dynamic Content Assembly, is the ability to create on-the-fly response data and content.

You can use Response Orchestration to dynamically create tailored, personalized data or web content for a specific set of users or devices. You can also source data and content from multiple server-side APIs or content origins. Response Orchestration supports conditions when combining multiple data sets or HTML fragments.

Use the ResponseProvider event handler to generate and manipulate response bodies within an EdgeWorkers function. When building your Edge solutions, you can fetch resources from other external origins and add them directly or indirectly into the main response body. This lets you make Edge decisions, build content, and optionally cache response output.

The diagram below illustrates how the responseProvider function generates a response, acting as a surrogate origin.

Get started with a code sample

To help you learn more about how to use the responseProvider event handler, we’ve added code samples to the Edgeworkers GitHub Repository.

Response Orchestration example

In this Response Orchestration example we use an EdgeWorkers function to modify an HTML response stream by adding content to the response. The script adds the content to the page just before the closing head tag.

You can modify this example to support the addition of various types of scripts to other sections of the HTML. You can also use HTTP sub-request functionality to dynamically add content to the page.

API Orchestration example

This API Orchestration example demonstrates how to use an EdgeWorkers function to merge multiple internal APIs into a single API response that is delivered to the user.

HTTP sub-requests made from EdgeWorkers functions provide numerous possibilities to generate API responses.