Create EdgeWorkers scripts for Virtual Waiting Room
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;
-
Create an EdgeWorker ID to enable the EdgeWorkers behavior in your โโAkamaiโ property configuration.
How to
- 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 orCUSTOM |
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 orfalse |
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);
}
- Create the code bundle.
- Deploy the code bundle.
- In โAkamai Control Centerโ. Go to โฐ > CDN > EdgeWorkers.
- Click on the EdgerWorker ID for Virtual Waiting Room with EdgeWorkers.
- Click the Create version button.
- Drag and drop the code bundle (
filename.tgz
) that you created in step 2, onto the window and click Create version. - Activate the version you just created.
- Select the
Staging
Network. After testing, activate the version in theProduction
Network.
Updated 9 months ago