Create EdgeWorkers scripts for Virtual Waiting Room (Standalone)

Follow these steps to create the EdgeWorkers main.js for Virtual Waiting Room.

The Virtual Waiting Room variables are defined in the main.js file. You also need to create a bundle.json file. The main.js and bundle.json are packaged together as a compressed .tgz file.

For more information, see create a code bundle.

Before you begin
Make sure you;

  1. Add EdgeWorkers to your contract.

  2. Create an EdgeWorker ID to enable the EdgeWorkers behavior in your ​​Akamai​ property configuration.

How to

  1. Set the values for the user-defined variables in the EdgeWorkers main.js. The variables must start with a PMUSER_ prefix and the name of the variables must be UPPERCASE as shown in the table.

Variables

Value

PMUSER_WR_ORIGIN_LIMIT

10 - 10000000 (integer value, users per second allowed to enter the origin)

For initial testing, you can use a smaller value such as 20.

PMUSER_WR_COOKIE_DOMAIN_CONFIG

HOST_HEADER or
CUSTOM

PMUSER_WR_COOKIE_DOMAIN

mydomain.com (example)

PMUSER_WR_ID

1 - 100 (integer value)

PMUSER_WR_PATH

/vwr/waiting-room.html (example)

PMUSER_WR_ASSETS_PATHS

/static/* /wr* (examples)

PMUSER_WR_SESSION_DURATION

0 - 86400 (integer value, seconds)

PMUSER_WR_SESSION_AUTO_PROLONG

true or
false

Example main.js with one waiting room

/*
(c) Copyright 2020 Akamai Technologies, Inc. Licensed under Apache 2 license.

Version: 0.2
Purpose:  EdgeWorker that generates a simple html page at the Edge and adds a response header
Repo: https://github.com/akamai/edgeworkers-examples/tree/master/edgecompute/examples/getting-started/hello-world%20(EW)
*/

// Import logging module
import { logger } from 'log';

export function onClientRequest (request) {
  logger.log('Executing EW for VP');
  request.setVariable('PMUSER_WR_ORIGIN_LIMIT', 20);
  request.setVariable('PMUSER_WR_COOKIE_DOMAIN_CONFIG', 'CUSTOM');
  request.setVariable('PMUSER_WR_COOKIE_DOMAIN', 'mydomain.com');
  request.setVariable('PMUSER_WR_ID', 1);
  request.setVariable('PMUSER_WR_PATH', '/vwr/waiting-room.html');
  request.setVariable('PMUSER_WR_ASSETS_PATHS', '*/vwr/assets/*');
  request.setVariable('PMUSER_WR_SESSION_DURATION', 300);
  request.setVariable('PMUSER_WR_SESSION_AUTO_PROLONG', true);
}
  1. Create the code bundle.
  2. Deploy the code bundle.
    1. In ​Akamai Control Center​. Go to > CDN > EdgeWorkers.
    2. Click on the EdgerWorker ID for Visitor Prioritization with FIFO (Standalone).
    3. Click the Create version button.
    4. Drag and drop the code bundle (filename.tgz) that you created in step 2, onto the window and click Create version.
    5. Activate the version you just created.
    6. Select the Staging Network. After testing, activate the version in the Production Network.

Did this page help you?