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
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:
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.
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.
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.
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)
}
Enable randomized page selection by intercepting inbound HTTP requests and serving content requests at the edge to specific control and test groups.
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)
}
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
Pricing is based on the number of requests a Worker processes at the edge. Every Cloudflare plan provides an allotted amount of CPU processor time that is specific to each plan.
(Up to 10 million requests)
Additional requests billed at $0.50 per million requests. Single script with up to 5 ms of CPU time.(Up to 10 million requests)
Additional requests billed at $0.50 per million requests. Single script with up to 10 ms of CPU time.(Up to 10 million requests)
Additional requests billed at $0.50 per million requests. Single script with up to 50 ms of CPU time.Not ready to purchase yet? Try Cloudflare Workers for free in the Workers playground