Cloudflare Workers

Run code at the edge, deliver powerful web extensibility

Increased security by applying custom security rules and filtering logic at the edge to detect malicious bots and prevent them from consuming resources.

Improve the user experience by incorporating more personalization and interactivity into static HTML pages with dynamic requests being run at the edge.

Lower operational costs by shifting more operational processes and request handling to the edge to improve cache hit rate and reduce bandwidth costs.

Already a customer? Activate Today

Sensitive internal application and data protected by Cloudflare Access.
"Moving away from VCL and adopting Cloudflare Workers will allow us to do some creative routing that will let us deliver JavaScript to npm's millions of users even faster than we do now. We will be building our next generation of services on Cloudflare's platform and we get to do it in JavaScript!"
CJ Silverio,
Chief Technology Officer at npm

The application consumer landscape is changing

Prior to Cloudflare Workers, there were two main places where developers could deploy code: front-end code running on an end user’s device, or back-end code running in a central data center. Both have their drawbacks. Cloudflare Workers gives developers a third place to deploy their code close to their customers — at the edge of Cloudflare’s ever-expanding global network — bringing the power and flexibility of a cloud data center, and the redundancy of a massively distributed system, within milliseconds of virtually every Internet user.

Developers can now build applications, that are increasingly complex and dynamic to meet the demands of consumers who want richer environments with greater personalization and flexibility. Customers can now maximize their existing investments to:

  • Reduce dependencies on their origin infrastructure
  • Improve cache hit rate
  • Streamline how applications communicate with an increasing number of APIs
  • Deliver a better user experience for users on any device or network
  • Mitigate the impact of malicious bots on their infrastructure
"At Postmates, customer trust is the most important thing. We needed a way to do a high volume of redirects without dedicating additional internal resources. Cloudflare Workers gave us a simpler way to build flexibility and fine-grained control into our systems at the edge."
Aabhas Sharma,
Infrastructure Lead at Postmates

Run code at the edge, not at the origin

Cloudflare Workers lets developers deploy JavaScript code at Cloudflare's edge, closer to the end user. Based on the Service Workers API, developers now have the ability to securely run code that is no longer bound to the browser on a user's device. Workers enable programmatic functionality for routing, filtering and responding to HTTP requests that would otherwise need to be run on a customer's server at the origin. Workers can be rapidly propagated across Cloudflare's global infrastructure within seconds.

Deliver personalized user experiences

Cache lightweight static HTML pages at the edge while incorporating dynamic content based on user location, device type or time of day. Run multiple background service requests either to the origin or third party Internet domains.

Quickly and easily add or remove users.
Quickly and easily add or remove users.

Increase API responsiveness

Aggregate responses from multiple API endpoints, and return as a single response, eliminating the need for each endpoint to compile individual responses. Each request can also be split into multiple parallel requests then combined into a single response.

Detect bot activity

Build conditional responses for inbound requests that can assess and block malicious bots from completing their requests. Set parameters that can identify and authorize legitimate traffic.

  
addEventListener('fetch', event => {
  event.respondWith(fetchAndApply(event.request))
})

async function fetchAndApply(request) {
  if (request.headers.get('user-agent').includes('annoying_robot')) {
    return new Response('Sorry, this page is not available.',
        { status: 403, statusText: 'Forbidden' })
  }

  return fetch(request)
}
  

Simplify A/B testing

Enable randomized page selection by intercepting inbound HTTP requests and serving content requests at the edge to specific control and test groups.

Easily identify users at the edge

Implement IP detection at the edge to determine where your users are connecting from. Enforce granular access policies with custom security rules and filters.

  
addEventListener('fetch', event => {
  event.respondWith(fetchAndApply(event.request))
})

async function fetchAndApply(request) {
  if (request.headers.get('cf-connecting-ip') === '225.0.0.1') {
    return new Response('Sorry, this page is not available.',
        { status: 403, statusText: 'Forbidden' })
  }

  return fetch(request)
}
  

Simplified onboarding and examples

An extensive library of code snippets and recipes that can be compiled to your environment in addition to examples in Cloudflare's Github repository. Join the Cloudflare Workers community site to learn from other users.

Key Features

V8 JavaScript

Apply custom logic expressions for routing and caching at the edge

Securely sandboxed using V8

Fast startup times at all locations

Return HTTP responses from the edge

Deployed to Cloudflare's data centers within seconds

Pre-scripted deployment recipes

Based on the W3C standard Service Workers API

"Cloudflare Workers saves us a great deal of time. Managing bot traffic without Workers would consume valuable development and server resources that are better spent elsewhere."
John Thompson,
Senior System Administrator at MaxMind

Everyone can start using Cloudflare Workers

Cloudflare protects and accelerates Internet applications and APIs. To start using Cloudflare Workers, you'll need a Cloudflare plan and an active Workers subscription.

Activate Today Already a customer?

Workers for Cloudflare's Free Plan

+ $5/Month

First 10M requests free;

$.50 per million thereafter


< 5ms CPU Processor Time


1 Script Included

Workers for Cloudflare's Pro Plan

+ $5/Month

First 10M requests free;

$.50 per million thereafter


< 10ms CPU Processor Time


1 Script Included

Workers for Cloudflare's Business Plan

+ $5/Month

First 10M requests free;

$.50 per million thereafter


< 50ms CPU Processor Time


1 Script Included

Workers for Cloudflare's Enterprise Plan

Custom

Custom Pricing


Negotiable CPU Processor Time


Unlimited Scripts Included

Live Webinar: How To Take Your DDoS Protection To The Next Level

 

Date/Time: Thursday, May 31st @ 11am PT