Subscribe to receive notifications of new posts:

Cloudflare Workers Recipe Exchange

06/04/2018

3 min read

Indian_Spices-1
Photo of Indian Spices, by Joe mon bkk. Wikimedia Commons, CC BY-SA 4.0.

Share your Cloudflare Workers recipes with the Cloudflare Community. Developers in Cloudflare’s community each bring a unique perspective that would yield use cases our core team could never have imagined. That is why we invite you to share Workers recipes that are useful in your own work, life, or hobby.

We’ve created a new tag “Recipe Exchange” in the Workers section of the Cloudflare Community Forum. We invite you to share your work, borrow / get inspired by the work of others, and upvote useful recipes written by others in the community.

Recipe Exchange in Cloudflare Community

We will be highlighting interesting and/or popular recipes (with author permission) in the coming months right here in this blog.

What is Cloudflare Workers, anyway?

Cloudflare Workers let you run JavaScript in Cloudflare’s hundreds of data centers around the world. Using a Worker, you can modify your site’s HTTP requests and responses, make parallel requests, or generate responses from the edge. Cloudflare Workers has been in open beta phase since February 1st. Read more about the launch in this blog post.

What can you do with Cloudflare Workers?

Cloudflare has an incredibly powerful global network of 151 data centers, where you can put compute anywhere and you can write with a language you’re familiar with (JavaScript) with a standard API you're familiar with (Service Workers). You can move your compute to be super low latency, to be much nearer to your end user, your database, your embedded device, or anything else you want faster round trips for.

You may access and leverage the power of Cloudflare’s network for your next applications or as an add-on for optimizing the performance of your existing projects by running JavaScript on Cloudflare’s edge network.

The next product that leverages Cloudflare's infrastructure to create security, performance, usability, and other optimizations for the Internet should have the lowest possible barriers to entry. Millions of customers should have access to those products on day one. That's how the Internet should work.

Cloudflare's Developer PlatformCloudflare's Developer Platform. See More≫

For inspiration, the Workers core team baked up some recipes to highlight a few popular use cases:

  • A/B Testing You can create a Cloudflare Worker to control A/B tests.
  • Aggregating Multiple Requests Here, we make multiple requests to different API endpoints, aggregate the responses and send it back as a single response.
  • Conditional Routing The easiest way to deliver different content based on the device being used is to rewrite the URL of the request based on the condition you care about.
  • Custom responses that don't hit origin servers You can return responses directly from the edge. No need to hit your origin.
  • Hot-link Protection You can use Cloudflare Workers to protect your hot-links on your web properties.
  • Post Requests Reading content from an HTTP POST request
  • Random Content Cookies You can create random content cookies using Cloudflare Workers.
  • Signed Requests A common URL authentication method known as request signing1 can be implemented in a worker with the help of the Web Crypto API.
  • Streaming Responses Minimize the visitor’s time-to-first-byte and the amount of buffering done in the worker script.

What if I want to just offer an idea or a use case?

That’s great! I’ve created this thread in the Cloudflare Community forum so anyone can submit a recipe idea, comment on one, and anyone can volunteer to write a recipe that there is a ready audience for.

Share your recipe in the Community Recipe Exchange

We protect entire corporate networks, help customers build Internet-scale applications efficiently, accelerate any website or Internet application, ward off DDoS attacks, keep hackers at bay, and can help you on your journey to Zero Trust.

Visit 1.1.1.1 from any device to get started with our free app that makes your Internet faster and safer.

To learn more about our mission to help build a better Internet, start here. If you're looking for a new career direction, check out our open positions.
Cloudflare WorkersCommunityDevelopersJavaScriptServerlessDeveloper Platform

Follow on X

Cloudflare|@cloudflare

Related posts