Current Page

Current Page

Current Page

Optimizing Cloudflare Worker Usage

Optimizing Cloudflare Worker Usage

Optimizing Cloudflare Worker Usage

Optimizing Cloudflare Worker Usage

Optimizing Cloudflare Worker Usage

Aug 19, 2025

Why Cloudflare Workers

Cloudflare Workers runs your code at the edge, offering excellent performance at low cost. It's simple to use and highly reliable, making it ideal for tasks like authentication, security checks, and request processing.

How Pricing Works

Cloudflare charges per worker invocation. The free plan includes 100,000 daily requests, while the Standard plan offers 10 million monthly requests plus $0.30 per additional million. Every time your worker runs, it counts toward these limits, so optimization matters.

The Problem with Wildcard Routes

When creating a middleware for all HTML pages, the easiest approach is to route all traffic through your worker using a wildcard like https://example.com/*. This ensures your worker processes every request, but there's a catch: it also runs for every CSS file, JavaScript file, and image on your site.

A single page load might trigger 30-50 worker invocations as it fetches various assets. Even if you check headers like "Sec-Fetch-Dest" to identify HTML requests, that check itself counts as an invocation. Your quota disappears quickly this way.

The Solution: Exclude Static Routes

The simple fix is to tell Cloudflare to skip your worker for specific routes entirely. In your Cloudflare Dashboard, select Worker Routes in the sidebar and click Add Route. Enter the pattern you want to exclude (like /static/*), select "None" in the Worker dropdown, and save. Now requests to those paths bypass your worker completely, saving your invocations for requests that actually need processing.

This works great for predictable paths where your static assets live, such as /images/*, /css/*, or /js/*. No code changes needed, just configuration.

Even Easier with OPTUX

If you're using OPTUX for A/B testing, excluding routes is even simpler. Navigate to your website's settings, find the Installation section, and look for the "Excluded URLs" option. Add your patterns with wildcards there, and OPTUX will automatically handle the Cloudflare configuration.

The Bottom Line

Smart routing isn't just about saving money. By excluding static assets from worker processing, you ensure faster delivery of images and stylesheets (served directly from Cloudflare's cache) while preserving worker resources for dynamic content that actually needs processing. Whether you're on the free tier or managing large applications, these simple exclusions make a huge difference in efficiency and cost

Why This Matters

At OPTUX, we've been running our own infrastructure on Cloudflare Workers for years, so we understand the importance of efficient worker usage firsthand. That's why we built route exclusion directly into our platform's interface. We believe performance optimization shouldn't require deep technical knowledge or complex configurations.

Our approach reflects our commitment to delivering not just the fastest A/B testing platform on the market, but also the most cost-effective one for our users. By automatically handling worker route optimization, we ensure your experiments run smoothly without unnecessarily inflating your Cloudflare bill.

Read more:

Conversion Tracking: A Complete Guide to Experiment Goals

Conversion tracking forms the backbone of successful A/B testing, and Optux.ai provides a comprehensive goal system that measures what matters most to your business. From simple button clicks and form submissions to complex custom JavaScript events and scheduling integrations with HubSpot and Calendly, the platform offers seven distinct goal types that capture every meaningful user interaction. By automatically tracking these conversions and applying statistical analysis to determine winning variants, Optux.ai transforms raw user behavior data into actionable insights that drive website optimization decisions, all while maintaining flicker-free performance and accurate attribution that's immune to ad blockers and privacy settings.

Aug 31, 2025

📁 A/B testing

📁 Split testing

📁 Targeting

Optimizing Cloudflare Worker Usage

Cloudflare Workers charges per invocation, and costs can quickly spiral when workers process every request including static assets. This comprehensive guide explains how to optimize your worker usage and dramatically reduce costs through strategic route exclusion.

Aug 19, 2025

📁 Cloudflare

📁 Installation

Content Security Policy (CSP) Header

Our Smart Agent automatically updates Content Security Policy (CSP) headers to enable smooth A/B testing without compromising browser security. Our cybersecurity-vetted solution eliminates manual CSP configuration, ensuring experiments run smoothly while maintaining strict security standards.

Aug 15, 2025

📁 A/B testing

📁 Installation

📁 Cloudflare

Whitelisting Outgoing IP Address

OPTUX uses a single static IP address for all outbound connections. Learn how to whitelist this IP in your system

Aug 17, 2025

📁 Installation

📁 Cloudflare