CloudEDGE Workers Overview

Introduction to CloudEDGE Workers

The Webscale CloudEDGE platform is a distributed cloud computing platform. It enables fast, personalized commerce and application content delivery to the edge. (The edge is the network location closest to where the user’s browser connects to Webscale). The platform includes CloudEDGE CDN and CloudEDGE Workers, which you can manage through the Webscale Control Panel.

The caching policies for your application specify how CloudEDGE CDN (also known as Webscale CDN) caches resources. They determine what resources are cached, how long they are cached, and how Webscale CDN processes requests for cache misses. The CloudEDGE Workers feature expands the functionality of Webscale CDN for your application by executing custom JavaScript code on the edge.

For information on CloudEDGE CDN and caching policies, see CloudEDGE CDN Overview and Configuring Webscale CDN Caching Policies.

For an illustration on how to use CloudEDGE Workers, see CloudEDGE Workers Usage Example.


CloudEDGE Workers feature

You can use the CloudEDGE Workers feature to easily extend your application’s functionality through custom JavaScript without changing your application code. It adds programmability and on-arrival code execution to Webscale CDN. Through CloudEDGE Workers, you can modify requests before they reach your application and responses before they reach the client.

CloudEDGE Workers provides a serverless execution environment. This means developers can write custom JavaScript code once with the option to deploy to multiple cloud providers without needing to change the application code. The CloudEDGE Workers feature takes care of writing, packaging, and distribution of the code.

The file that includes your JavaScript source files as a NPM package is known as a handler file. Each exported JavaScript function can process requests or responses (but not both) and must conform strictly to the handler interface. The handler file can have more than one function.

A handler incorporates the handler file. When you configure a handler, you choose one function from the handler file to run. The caching policy with which the handler is associated determines when the function runs. Associating a handler with the CDN control for the policy creates a CloudEDGE worker. Currently, workers execute after cache misses.

Workers can do everything from optimizing cached images to injecting security cookies.

Procedure for working with CloudEDGE Workers

You can use the following procedure to work with handlers and workers. The Webscale Control Panel enables you to manage handlers and workers. For information on creating handlers and workers, see Working with CloudEDGE Handlers and Workers.

Upload handler files

Handler files adhere to the common structure used for NPM packages with some additional constraints. You can upload handler files to your account through the Files page. All applications for your account can then use the file for their handlers.

The Files page enables you to view all files in the NPM package and their contents. You can also use this page to download, replace, edit, and delete handler files.

For information about uploading files, see Working with Files.

For information about creating handler files, see Creating Handler Files.

Create handlers

When you create a handler, you configure the following settings.

  • Name
  • Description (optional)
  • Provider
  • Handler file
  • Function
  • Memory

When you select the provider, you can only choose a provider that has Webscale CDN and CloudEDGE Workers enabled for it.

You can only select one function for a handler. It can be either a request or response function that deploys as a request or response worker.

The memory setting specifies the maximum amount of computing resources that the provider will allocate to the worker during execution.

Create workers

Caching policies specify the workers that will run. Each CDN control for a caching policy has settings that enable you to associate handlers with the control, which results in a worker. By default, CDN controls do not have handlers associated with them. You can select a request handler, response handler, or both for a control. When creating the control, you define when the worker runs.

A worker with a request function executes before Webscale CDN forwards the request to origin. A worker with a response function runs in conjunction with the origin response.

When you have a CDN control with two handlers, the CDN control will have a worker for each type of function. For a cache miss, the request and response workers for the CDN control will both run.

Worker execution

CDN controls determine how Webscale CDN responds to incoming requests for assets. It compares the path for each request to the request paths for your CDN controls. If Webscale CDN finds a match, it searches for the resource in its cache.

When a cache “miss” occurs, Webscale CDN forwards the request to your application and the worker with a request handler runs. When your application sends a response, the response worker executes.

Further reading

Have questions not answered here? Please Contact Support to get more help.

Last modified September 20, 2023