Review these common questions about EdgeWorkers content transformation. To learn more, review the the Response content transformation tutorial in this guide.
You can put your own transformation logic in place. To implement advanced metadata you need support from Akamai.
Unlike ESI, EdgeWorkers functions can transform content by streaming it. Streaming lets the EdgeWorkers function respond to the client with the initial content, before it receives the full content from the origin. EdgeWorkers delivers the initial cacheable content at the beginning of the response while waiting on non-cacheable content later in the response. This can improve Time to First Byte (TTFB).
When you insert an EdgeWorkers function "inline" with an existing request or response, it cannot read the response body directly. There are four different event handlers that can execute when the EdgeWorkers function is inline with a request or response. These are
onClientResponse. None of these event handlers have access to the response body.
responseProvider can produce large responses. However, when added to an EdgeWorkers function,
responseProvider replaces the origin request.
Response modification is the combination of two separate capabilities:
- The ability to generate an HTTP response from
- The ability to act as an HTTP client and make outbound sub-requests from the EdgeWorkers code.
By combining these capabilities, you can design an EdgeWorker function that:
- Is invoked on a URL.
- Makes a sub-request to a second URL.
- Reads the response content from the sub-request.
- Modifies the response content as needed.
- Returns the modified content back to the end-user.
The end result is the equivalent of modifying the body content.
responseProvider function acts like the origin, and can be cached just as any other origin request.
Can I use the same URL for the EdgeWorkers code and origin to "transparently" modify the content of an existing URL?
This is also possible. The EdgeWorkers code can make an HTTP sub-request to the same URL that initiated the EdgeWorkers execution. EdgeWorkers are not allowed to execute on sub-requests, so you don't have to worry about an infinite loop. There are some nuanced implementation details, especially if caching of the original and transformed content is required. For more information, refer to the Response content transformation topic in this guide.
All EdgeWorkers limits apply, including CPU time, wall time, and memory limits. Additionally, the request to retrieve the original content must complete within the maximum wall time allowed per HTTP sub-request. Refer to the Resource tier and Product limits for more information.
Updated 7 months ago