EdgeWorkers

Learn how to execute JavaScript functions at the edge to optimize site performance and customize web experiences.

Get Started    

About the JavaScript API

Review these details when designing EdgeWorkers functions. To learn more about the specific HTTP events that can execute an EdgeWorkers script, see Event handler functions.

👍

For information about the supported HTTP methods see, Event handler methods.

Event Handler Function Support Matrix

View this event handler support matrix for information about the EdgeWorkers JavaScript objects, attributes, and functions each event type supports.

Event HandlerUse CasesMethods
onClientRequestRedirect Management

Traffic Filtering
Allow / Deny
Static Response Offload

respondWith()
Header ManagementgetHeader()

setHeader()
addHeader()
removeHeader()

Cookie Managementcookies

toHeader()
get()
getAll()
names()
add()
delete()

See the note below.

Delivery Property Flow ControlgetVariable()

setVariable()

Conditionally Route Traffic

Personalization

route()
Cache Key ManipulationexcludeQueryString()

includeQueryString()
includeQueryArgument()
includeCookie()
includeHeader()
includeVariable()

onOriginRequest

onOriginResponse
onClientResponse

Header ManagementgetHeader()

setHeader()
addHeader()
removeHeader()

Cookie Managementcookies

toHeader()
get()
getAll()
names()
add()
delete()

See the note below.

Delivery Property Flow ControlgetVariable()

setVariable()

responseProviderResponse OrchestrationhttpRequest()

text()
json()
getHeader()
getHeaders()
createResponse()

To use the responseProvider functions, you need to
import the create-response, streams,
text-encode-transform, and http-request modules.

Manipulate the response (body, headers)createResponse()

📘

Cookie Management methods

To use theCookie Management methods, you need to import the cookies module.

Updated 2 months ago


About the JavaScript API


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.