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?
What can you do with Cloudflare Workers?
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 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.