Custom Domains·5 min read·

How do I configure Cloudflare caching for a Next.js blog without breaking dynamic routes?

Bypass /api/* first, then Cache Everything on the root — order matters. Verify with cf-cache-status: BYPASS on API calls in devtools.

To configure Cloudflare caching for your Next.js VeloCMS blog without breaking dynamic routes, you must create custom Page Rules that explicitly bypass the cache for your API endpoints while aggressively caching your static front-end assets. Doing this guarantees your public posts load lightning-fast from the edge network without freezing up the dynamic, real-time features that power the platform.

Why does a blanket cache break Next.js dynamic routing?

You've probably noticed that turning the Cloudflare caching dial all the way up sounds fantastic in theory. Faster load times usually mean happier readers and better search rankings, right? The catch is that modern frameworks like Next.js rely heavily on specific server-side requests to handle anything dynamic. We're talking about live search functionality, protected admin dashboards, or those on-the-fly AI content drafts you're generating inside VeloCMS. Whenever Cloudflare blindly caches the entire domain, it essentially traps those interactive pages in time. You might hit publish on a brand-new post, but the front page stubbornly displays yesterday's news. Because VeloCMS leans on PocketBase to deliver that secure, lightning-fast database magic, a lazy "cache everything" approach ends up suffocating the exact features that make this setup vastly superior and cheaper than a bloated WordPress installation. The CDN just stops asking your server for fresh data.

What exact Cloudflare Page Rules should I create?

This is where we roll up our sleeves and clear out the routing bottleneck. You'll want to log into your Cloudflare dashboard, navigate to the Rules section, and dive straight into Page Rules. Your very first order of business is building a protective shield around your backend. Create a new rule targeting exactly *yourdomain.com/api/* and set the Cache Level to "Bypass". This specific, actionable tweak is an absolute lifesaver because it commands Cloudflare to step aside and let PocketBase and your Next.js backend communicate naturally. Once that API bypass is safely saved, you can add a second rule for *yourdomain.com/* with the Cache Level cranked up to "Cache Everything" and an Edge Cache TTL of a couple of hours. Here's the crucial part: make sure the bypass rule sits above the catch-all rule in your dashboard list (Cloudflare always reads these rules from top to bottom!). By organizing them this way, your main blog pages serve up instantly from local edge servers, yet the moment you log in to tweak an AI prompt, the system instinctively fetches fresh data directly from PocketBase.

How can I test if my dynamic content is actually bypassing the cache?

Nobody wants to just cross their fingers and guess if their site is working properly. After you save those routing rules, open a fresh incognito window and pop open your browser's developer tools. Head over to the Network tab, load up one of your dynamic admin routes, and click on the primary document request at the top of the waterfall. You're hunting for a specific response header named cf-cache-status. If you see that header reading BYPASS or DYNAMIC on your API network calls, you nailed the configuration perfectly. If it screams HIT instead, you've definitely got some wires crossed in your Page Rules order and need to double-check the list hierarchy. I usually run a practical test by dropping a quick edit into a PocketBase text record and then refreshing the live webpage. If that text edit shows up instantly, your dynamic routes are breathing easy.

Dialing in these network settings definitely takes a little bit of trial and error, but getting the balance right is totally worth the temporary headache. You end up capturing all the incredible speed benefits of a global content delivery network without sacrificing the bleeding-edge AI architecture that makes VeloCMS run circles around traditional, clunky platforms. Play around with the expiration timers once you feel confident, keep an eye on your network headers, and enjoy your incredibly fast new blog.