The StackPath Developer Portal

Integrate our platform directly into your products and dynamically protect your edge.

Get Started    API Reference

Introduction

What Is Serverless Scripting?

StackPath's serverless scripting computing platform that allows you to upload JavaScript scripts and have them automatically deployed within seconds to every StackPath datacenter worldwide. There, the scripts can interact with every request that comes into your site (or just the requests you define) and do things like modify the request or response bodies, make decisions based on the request headers or a number of additional StackPath headers, make additional fetch queries, or even respond to the request directly without having to send it to your origin. Just a few of the many possible uses are available in our serverless scripting support section for you to review.

To activate serverless scripting you will need to first make sure you have our CDN service enabled, which you can simply do by purchasing CDN on its own, or within one of our edge delivery stacks (recommended).

Why Use Serverless Scripting?

Serverless computing allows developers to focus on what's important - coding their application. Once the code is ready, it can be deployed to a serverless environment without the need for the developer to worry about where it's being deployed, provisioning servers or containers, creating failover or scaling plans, etc. StackPath's serverless scripting takes the traditional concept a step further by allowing developers to deploy to the edge, in data centers all over the world, with one button (or API call) in a matter of seconds. Positioning JavaScript code at the edge puts it close to end users, allowing developers to apply logic to each and every request they get and return responses or modify requests right there by the user before the requests even go back to the origin server. Such a setup means developers get a simple and easy way to deploy highly-distributed, highly-performant, and highly-scalable global applications.

How Does It Work?

Serverless scripts are executed in the StackPath data center closest to a given end user. When a user's request comes in, we execute your JavaScript code in an individual, isolated sandbox environment built on StackPath's custom implementation of the V8 JavaScript Engine. V8 is an open-source JavaScript engine created by Google and used by the Chrome browser as well as many other well-known pieces of software. Because V8 is open-source and widely used, it is highly secure (Google itself is very motivated to keep it that way) and StackPath has added even more security mechanisms to keep your code secure and completely separate from anyone else's. Using V8 also allows your code to be started extremely quickly, whether it's being run for the first time or the thousandth.

When a user request comes into a StackPath data center and your code is executed in the V8 engine, your code is executing before StackPath's CDN cache or WAF services. This ordering means you have complete control over incoming requests before StackPath responds to them, and can manipulate (or block) requests before StackPath responds or they get to your origin server.

What Is Serverless Scripting Not?

Serverless scripting gives developers incredible capability and flexibility to easily deploy serverless applications around the world, but there are still a few things it is not. To be clear and transparent about what those are, we thought we should list those here:

  • Serverless scripting is not a replacement for or alternative to the StackPath CDN. CDN service is required to run serverless scripts.
  • Serverless scripting does not yet support languages other than JavaScript (though support for additional language support is coming), or deployment concepts other than serverless computing, e.g. containers or VMs.
  • Serverless scripts live and die per request; the code is not continuously running in the background.

What's Next

Getting Started

Introduction


Suggested Edits are limited on API Reference Pages

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