A new Workers Best Practices guide provides opinionated recommendations for building fast, reliable, observable, and secure Workers. The guide draws on production patterns, Cloudflare internal usage, and best practices observed from developers building on Workers.
Key guidance includes:
- Keep your compatibility date current and enable
nodejs_compat— Ensure you have access to the latest runtime features and Node.js built-in modules.
wrangler.jsonc
{"name": "my-worker","main": "src/index.ts",// Set this to today's date"compatibility_date": "2026-02-17","compatibility_flags": ["nodejs_compat"],}wrangler.toml
name = "my-worker"main = "src/index.ts"# Set this to today's datecompatibility_date = "2026-02-17"compatibility_flags = [ "nodejs_compat" ]
- Generate binding types with
wrangler types— Never hand-write yourEnvinterface. Let Wrangler generate it from your actual configuration to catch mismatches at compile time. - Stream request and response bodies — Avoid buffering large payloads in memory. Use
TransformStreamandpipeToto stay within the 128 MB memory limit and improve time-to-first-byte. - Use bindings, not REST APIs — Bindings to KV, R2, D1, Queues, and other Cloudflare services are direct, in-process references with no network hop and no authentication overhead.
- Use Queues and Workflows for background work — Move long-running or retriable tasks out of the critical request path. Use Queues for simple fan-out and buffering, and Workflows for multi-step durable processes.
- Enable Workers Logs and Traces — Configure observability before deploying to production so you have data when you need to debug.
- Avoid global mutable state — Workers reuse isolates across requests. Storing request-scoped data in module-level variables causes cross-request data leaks.
- Always
awaitorwaitUntilyour Promises — Floating promises cause silent bugs and dropped work. - Use Web Crypto for secure token generation — Never use
Math.random()for security-sensitive operations.
To learn more, refer to Workers Best Practices.
Source: Cloudflare
Latest Posts
- (Updated) Microsoft 365 Copilot: Voice chat in Microsoft 365 Copilot [MC1189001]
![(Updated) Microsoft 365 Copilot: Voice chat in Microsoft 365 Copilot [MC1189001] 2 pexels pixabay 159868](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)
- (Updated) OneDrive: Simplified file transfer for departing employees [MC1164381]
![(Updated) OneDrive: Simplified file transfer for departing employees [MC1164381] 3 pexels pixabay 50577](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)
- (Updated) Microsoft 365 Copilot: Copilot chats in search results [MC1189002]
![(Updated) Microsoft 365 Copilot: Copilot chats in search results [MC1189002] 4 pexels pixabay 277092](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)
- (Updated) Microsoft 365 Copilot: Podcast voice interactions make audio experiences conversational [MC1183009]
![(Updated) Microsoft 365 Copilot: Podcast voice interactions make audio experiences conversational [MC1183009] 5 pexels brett sayles 1597776](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)

![(Updated) Microsoft 365 Copilot: Voice chat in Microsoft 365 Copilot [MC1189001] 2 pexels pixabay 159868](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-pixabay-159868-150x150.webp)
![(Updated) OneDrive: Simplified file transfer for departing employees [MC1164381] 3 pexels pixabay 50577](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-pixabay-50577-150x150.webp)
![(Updated) Microsoft 365 Copilot: Copilot chats in search results [MC1189002] 4 pexels pixabay 277092](https://mwpro.co.uk/wp-content/uploads/2025/06/pexels-pixabay-277092-150x150.webp)
![(Updated) Microsoft 365 Copilot: Podcast voice interactions make audio experiences conversational [MC1183009] 5 pexels brett sayles 1597776](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-brett-sayles-1597776-150x150.webp)
![(Updated) Microsoft Teams: Private chat for organizers and presenters in structured meetings, webinars, and town halls [MC1188222] 7 (Updated) Microsoft Teams: Private chat for organizers and presenters in structured meetings, webinars, and town halls [MC1188222]](https://mwpro.co.uk/wp-content/uploads/2025/06/palm-2445110_1920-96x96.webp)