Browser Rendering API reaches general availability

The Browser Rendering API is now generally available to all paid Workers customers, moving beyond its open beta from May 2023. The API gives developers programmatic control over a headless browser instance within Workers, enabling automation flows built on the companion Puppeteer library that Cloudflare released alongside the beta.

Browser Rendering API GA, rolling out Cloudflare Snippets, SWR, and bringing Workers for Platforms to all users

The key addition in this release is session management, a frequently requested feature from the beta community. Previously, reusing a browser across multiple Worker invocations required custom logic built on Durable Objects. With session management, browsers can stay running in the background, and developers can access them through new methods in the Puppeteer API, along with visibility into active sessions, activity history, and limits.

Listing running sessions is now a straightforward call:

const sessions = await puppeteer.sessions(env.RENDERING);
console.log(sessions);
[
   {
      "connectionId": "2a2246fa-e234-4dc1-8433-87e6cee80145",
      "connectionStartTime": 1711621704607,
      "sessionId": "478f4d7d-e943-40f6-a414-837d3736a1dc",
      "startTime": 1711621703708
   },
   {
      "sessionId": "565e05fb-4d2a-402b-869b-5b65b1381db7",
      "startTime": 1711621703808
   }
]

A full Worker script demonstrating session reuse is available in the developer documentation.

Observability for Browser Rendering usage is integrated into the dashboard under the Worker & Pages section, with detailed analytics and logs.

BLOG-2308 Embedded Image - 3PAWRV

During the launch period, each paid Workers account is limited to two new browsers per minute and two concurrent browsers at no cost. Getting started instructions are on the developers page.

Cloudflare Snippets begin phased rollout

Cloudflare Snippets, the programmable layer for complex HTTP request and response modifications, is starting a phased rollout after showing strong early adoption. In the first quarter of 2024 alone, Snippets traffic grew more than 7x, from roughly 2,200 requests per second in early January to over 17,000 by March.

BLOG-2308 Embedded Image - 8emnQN

Rather than making Snippets available to all users at once, Cloudflare is pacing the release: over the next few weeks, 5% of users will see a "Snippets" entry under the Rules tab in the zone-level dashboard. This mirrors the Gradual Rollouts approach used for Workers.

Those in the initial cohort are encouraged to test Snippets for advanced use cases such as dynamic header date modification or A/B testing using math.random. The feature remains in alpha, so it is not recommended for production traffic.

BLOG-2308 Embedded Image - 7NRPEh

More detail on Snippet capabilities is available in the developer documentation.

Stale-while-revalidate coming to the CDN

Cloudflare has announced that asynchronous revalidation with the stale-while-revalidate (SWR) cache directive will arrive in the second half of 2024. The feature is being built into the new CDN architecture, which is written in Rust with performance and memory safety as priorities.

The current behavior when a requested asset has expired is to connect to the origin and fetch a fresh version before responding to the client, adding latency to those requests. With SWR, the stale copy is served to the end user immediately while Cloudflare checks the origin in the background. If a newer version is available, it replaces the cached copy. This trades a small window of staleness for faster response times.

Interested customers can register for the beta testing program here.

Workers for Platforms opens to pay-as-you-go plans on April 16

Starting April 16, 2024, Workers for Platforms will be available through a new $25 pay-as-you-go plan. The product lets platform builders deploy custom code on behalf of their users, or let users deploy their own code, without infrastructure management.

Workers for Platforms supports all standard Workers bindings — including Workers AI, D1, and Durable Objects — as well as Python Workers.

Several customers are already building on the platform:

  • Shopify Oxygen — a hosting platform for Shopify's Remix-based Hydrogen eCommerce framework. It gives merchants control over the buyer experience beyond generic storefront templates.
  • Grafbase — a serverless GraphQL API platform that unifies business data sources. Developers on Grafbase can deploy JavaScript/TypeScript or WASM code through Workers for Platforms.
  • Triplit — an open-source database syncing data between server and browser in real time. Its query and sync engine runs on Durable Objects, and customers can package custom JavaScript alongside their Triplit DB instance.

Platform operators also get several controls for observability and governance:

  • Custom Limits — set CPU time or subrequest caps on user Workers to control costs or shape pricing tiers.
  • Tail Workers — capture live logs, console messages, and unhandled exceptions from user Workers for real-time debugging.
  • Outbound Workers — intercept all outgoing fetch() requests from user Workers for full visibility before requests leave the platform.

The $25 pay-as-you-go plan is designed to be accessible to hobbyists and indie developers.

Included Amounts
Requests 20 million requests/month
+$0.30 per additional million
CPU time 60 million CPU milliseconds/month
+$0.02 per additional million CPU milliseconds
Scripts 1000 scripts
+0.02 per additional script/month

Workers for Platforms will be purchasable from the Workers for Platforms tab in the Cloudflare Dashboard on April 16, 2024. In the meantime, developers can explore a starter project and the developer documentation.