AI Crawlers & Bot Traffic: Cut Serverless Bills Without Hurting SEO

Stop scrapers from spiking Vercel Fluid Compute and Worker bills while keeping Googlebot, GPTBot, ClaudeBot, and PerplexityBot indexing at $0 CDN egress.

Checked 4 Dec 2026·Published 4 Dec 2026·9 min read·Raw .md
In brief
  • Never flip on blanket 'Under Attack Mode' to stop a serverless bill spike, doing so blocks Googlebot, Bingbot, OAI-SearchBot, GPTBot, ClaudeBot, PerplexityBot, and signed webhooks.
  • Serve static HTML, /llms.txt, and clean .md mirrors from CDN edge cache (or Cloudflare Workers Static Assets at $0.00/GB egress) so 1,000,000 crawler reads cost $0 in compute.
  • Add Cache-Control: public, s-maxage=3600, stale-while-revalidate=86400 to semi-dynamic SSR routes, strip ?utm_* and ?fbclid cache-busting params, and scope WAF 429 rate limits strictly to /api/* and /search.

Why does AI and scraper traffic explode serverless bills while human traffic stays flat?

Automated scrapers bypass browser caches, enumerate tens of thousands of faceted URL and query-string permutations per hour, and trigger cold dynamic SSR, database queries, and origin transfers on every request. On metered platforms like Vercel Pro ($20/seat/mo) or dynamic Workers, uncached bot floods turn $0 static pageviews into runaway Fluid Compute, Fast Origin Transfer, and database row-read charges.

On a traditional fixed-price VPS ($14.50/mo for 4 vCPU / 8 GB RAM and 20 TB included bandwidth), an aggressive scraper wave temporarily raises CPU utilization to 70% and adds $0.00 to your monthly invoice. On usage-metered serverless stacks, every uncached HTTP request wakes compute, allocates memory, transfers origin payloads, and queries downstream databases:

  • Vercel Pro Compute & Transfer Meters: Beyond the $20 monthly usage credit per $20 seat, dynamic rendering bills Fluid Compute Active CPU at $0.128/hour plus Provisioned Memory at $0.0106/GB-hour, Fast Origin Transfer at $0.06/GB above just 10 GB, Fast Data Transfer at $0.15/GB above 1,000 GB (1 TB), and Image Optimization at $0.06 per 1,000 transformations (see fixing Next.js image optimization bill spikes).
  • Cloudflare Workers Paid Meters ($5.00/mo base): Static assets bill $0.00/GB egress and zero request charges, whereas requests routed into dynamic Worker scripts include 10,000,000 invocations per month and bill $0.30 per extra million requests, plus any D1, KV, or external Postgres read amplification inside the handler.

Look at why non-human traffic hits those meters so hard:

  1. Query-string cache busting: Scrapers harvesting pricing directories or catalogs append ?utm_source=..., ?ref=..., ?page=412, or ?sort=newest. When SSR treats unknown query strings as dynamic inputs, 50,000 hits to the same route miss CDN cache 50,000 times.
  2. Accidental dynamic opt-in: Reading cookies() or headers() inside a shared Next.js root layout.tsx forces public routes to emit Cache-Control: private, no-cache, no-store, running Server Components and database reads on every bot hit.
  3. Panic mitigation backfires: Enabling Cloudflare "I'm Under Attack Mode" on /* or pasting blanket Disallow: / rules breaks Google Search Console indexing, Slack/X OpenGraph previews, Stripe webhooks, and citations in ChatGPT (OAI-SearchBot), Claude (ClaudeBot), and Perplexity (PerplexityBot).

Compare how uncached SSR vs edge-cached static delivery changes your monthly invoice in the Vercel vs Cloudflare Monthly TCO Calculator.

Which bots should you allow at the CDN edge vs Rate-Limit or block?

Allow cryptographically or reverse-DNS verified search, answer-engine citation, and social preview bots (Googlebot, Bingbot, OAI-SearchBot, GPTBot, ClaudeBot, PerplexityBot, Slackbot) onto edge-cached HTML, /llms.txt, and .md mirrors, while blocking spoofed crawler User-Agents (not cf.client.bot) and rate-limiting /api/* and faceted /search endpoints.

Not all automated traffic has the same economic value or cost profile. Separate incoming non-human requests into four explicit operational tiers before writing a single robots.txt or WAF rule:

Bot Tier & Examples Discovery / Revenue Value Identity Verification Allowed Surface Exact Cost-Protection Action
Tier 1: Search & Answer Engines (Googlebot, Bingbot, Applebot, OAI-SearchBot, PerplexityBot, ClaudeBot, GPTBot) High (SEO rankings + AI answer citations) cf.client.bot / published IP CIDR & rDNS Static HTML, /llms.txt, /*.md, sitemaps Allow at $0 CDN edge; Disallow: /api/ and /*?sort=* in robots.txt
Tier 2: Social Unfurlers & Webhooks (Slackbot, Twitterbot, Discordbot, Stripe/GitHub webhooks) High (link shares + payment/CI events) cf.client.bot or HMAC request signature Canonical pages, cached OG images, /api/webhooks/* Allow; cache /og/* with s-maxage=604800; exempt /api/webhooks/* from IP challenges
Tier 3: Commercial SEO Backlink Bots (AhrefsBot, SemrushBot, DotBot, MJ12bot) Low–Medium (useful only if you use their SEO suites) cf.client.bot Canonical HTML only Serve strictly from CDN cache; block faceted query strings (?filter=*); throttle MJ12bot
Tier 4: Spoofed Bots & Headless Scrapers (python-requests, fake Googlebot on residential/cloud ASNs) Zero / Negative (credential stuffing, content theft, bill spikes) Fails cf.client.bot (not cf.client.bot) Public cached HTML at normal human pace Immediate 403 Block on spoofed bot UAs; 429 Rate Limit on /api/* & /search

Notice the critical distinction between Tier 1 and Tier 4: robots.txt only governs polite Tier 1–3 crawlers. If you block GPTBot and ClaudeBot in robots.txt, honest citation bots stop indexing your docs while abusive Tier 4 Python scrapers keep hammering /api/search at 300 requests/second. The real fix is making Tier 1 reads free to serve while stopping Tier 4 compute abuse at the edge WAF.

How do you serve search and AI crawlers for $0 with static HTML, /llms.txt, and .md mirrors?

Pre-render public pages as static HTML, publish /llms.txt alongside clean Markdown mirrors (/guides/<slug>.md), and host static assets on a zero-egress edge layer such as Cloudflare Workers Static Assets ($5/mo Paid base, $0.00/GB static egress). Legitimate search and AI crawlers get fast, clean text while triggering zero serverless CPU invocations.

Answer engines (OAI-SearchBot, ClaudeBot, PerplexityBot) and search crawlers (Googlebot, Bingbot) do not want client-hydrated JavaScript bundles, session cookies, or live database queries, they want authoritative headings, tables, JSON-LD (Article / FAQPage), and clean prose.

When you export static routes or generate .md mirrors at build time (see deploying Next.js static exports on Cloudflare Workers without trailing-slash 404s), Cloudflare serves HTML, /llms.txt, and .md files straight from edge storage:

  • Static Asset Egress: $0.00/GB on Cloudflare Workers.
  • Worker Compute Invocations: 0 billed requests when a request matches a static asset directly without invoking a Worker script.
  • Database Reads: 0 queries because pricing tables and runbooks are compiled during CI on 1x Linux runners ($0.008/min; see cutting CI/CD runner bills).

Publish a concise public/llms.txt index pointing AI agents directly to lightweight .md mirrors instead of forcing them to crawl paginated UI routes:

# StackQuota
> Independent cloud, AI API, mobile app store, and CI/CD cost calculators and verified billing runbooks.

Calculators:
- [Vercel vs Cloudflare & CI/CD Monthly TCO](https://stackquota.com/calculators/vercel-vs-cloudflare-tco/)

Verified Engineering Runbooks (Markdown Mirrors):
- [Next.js Image Optimization Bill Spike Fix](https://stackquota.com/guides/nextjs-image-optimization-bill-spike-cloudflare-loader-fix.md)
- [GitHub Actions macOS 10x Runner Minutes Fix](https://stackquota.com/guides/github-actions-macos-runner-minutes-burn-ios-cache-fix.md)
- [SEO-Safe AI Crawler & Serverless Bill Protection](https://stackquota.com/guides/ai-crawlers-bot-traffic-serverless-bill-protection-seo-safe.md)

Pair /llms.txt with a surgical public/robots.txt that welcomes search and AI citation bots onto canonical content while keeping them out of dynamic APIs and infinite filter permutations:

# public/robots.txt — Welcome search & AI citation bots; block expensive dynamic traps
User-agent: Googlebot
User-agent: Bingbot
User-agent: OAI-SearchBot
User-agent: GPTBot
User-agent: ClaudeBot
User-agent: PerplexityBot
Allow: /
Allow: /llms.txt
Allow: /guides/*.md
Disallow: /api/
Disallow: /auth/
Disallow: /*?sort=*
Disallow: /*?filter=*
Disallow: /*?q=*

User-agent: *
Allow: /
Disallow: /api/
Disallow: /auth/
Disallow: /*?sort=*
Disallow: /*?filter=*
Disallow: /*?q=*

Sitemap: https://stackquota.com/sitemap.xml

A single 18 KB .md mirror transfers 10x fewer bytes than a 180 KB hydrated HTML+RSC payload and gives LLM retrieval pipelines exact tables and code blocks without scraping every UI link on the page.

How do you fix Cache-Control headers and strip Query-String cache busting?

Add Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=86400 to semi-dynamic SSR routes and strip marketing or scraper query parameters (utm_*, fbclid, gclid, ref) at the CDN edge before requests reach your origin. That collapses 100,000 hourly bot hits down to a single background revalidation per hour.

Not every route in a SaaS product can be a build-time static file, public user profiles, status pages, community threads, and live directory listings change throughout the day. Yet rendering those pages dynamically on every request is almost never necessary for anonymous visitors and bots.

First, ensure anonymous Next.js routes or API read endpoints set explicit shared-cache (s-maxage) headers rather than relying on framework defaults that accidentally degrade to private, no-store:

// app/directory/[category]/route-cache-headers.js (or next.config.mjs headers())
export async function headers() {
  return [
    {
      source: '/directory/:category*',
      headers: [
        {
          key: 'Cache-Control',
          // Browsers revalidate (max-age=0), CDN caches 1 hr (s-maxage=3600),
          // and serves stale instantly for 24 hrs while revalidating in background!
          value: 'public, max-age=0, s-maxage=3600, stale-while-revalidate=86400',
        },
      ],
    },
  ];
}

With s-maxage=3600, stale-while-revalidate=86400, if 40,000 scrapers request /directory/databases during a one-hour spike, 39,999 requests are absorbed by the CDN edge and your Fluid Compute / database origin runs once.

Second, close the query-string cache-busting loophole. By default, /directory/databases?utm_source=scraper1 and /directory/databases?fbclid=IwAR992 create separate cache misses if your SSR framework inspects searchParams. Strip cosmetic tracking and cache-busting parameters inside a tiny edge middleware or Cloudflare Cache Rule before lookup:

// worker/normalize-cache-key.js (Cloudflare Worker front-door snippet)
const STRIP_PARAMS = new Set([
  'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',
  'fbclid', 'gclid', 'msclkid', 'mc_cid', 'mc_eid', 'ref', '_hsenc',
]);

export async function fetchNormalized(request, env) {
  const url = new URL(request.url);

  // Never mutate /api/* or signed webhook query strings
  if (!url.pathname.startsWith('/api/')) {
    for (const key of [...url.searchParams.keys()]) {
      if (STRIP_PARAMS.has(key.toLowerCase())) {
        url.searchParams.delete(key);
      }
    }
  }

  const normalizedRequest = new Request(url.toString(), request);
  return env.ASSETS.fetch(normalizedRequest);
}

On Cloudflare Pro/Free zones without a custom Worker, you can achieve the exact same behavior with zero code under Caching -> Cache Rules by setting Query String -> Ignore query string on static/marketing path prefixes (/guides/*, /blog/*, /pricing/*).

How do you write surgical Cloudflare WAF Rate-Limiting rules on /api/* without false positives?

Deploy two targeted Cloudflare WAF rules: a Custom Rule that immediately 403 blocks spoofed search/AI crawler User-Agents failing cf.client.bot, and a Rate Limiting Rule (HTTP 429 with Retry-After) scoped strictly to /api/* (excluding /api/webhooks/*) and dynamic /search endpoints.

Blanket JavaScript challenges on / hurt Core Web Vitals, break RSS readers, and risk SEO de-indexing. Instead, leave cached HTML open and put hard walls around the endpoints that actually burn CPU, LLM tokens, or database reads:

WAF custom rule 1: drop spoofed search & AI crawler User-Agents (403 Forbidden)

Scrapers routinely set User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; ...) or GPTBot/1.0 hoping site owners whitelist crawler strings naively. Cloudflare maintains real-time ASN and reverse-DNS verification in cf.client.bot:

# Cloudflare WAF -> Custom Rules -> Action: Block
(
  http.user_agent contains "Googlebot" or
  http.user_agent contains "Bingbot" or
  http.user_agent contains "Applebot" or
  http.user_agent contains "GPTBot" or
  http.user_agent contains "OAI-SearchBot" or
  http.user_agent contains "ClaudeBot" or
  http.user_agent contains "PerplexityBot"
) and not cf.client.bot

Real Google, Bing, Apple, OpenAI, Anthropic, and Perplexity crawlers evaluate cf.client.bot == true and sail right past this rule; every cheap scraper faking their identity gets dropped at the network edge for $0.00.

WAF rate limiting rule 2: throttle /api/* & /search (429 Too Many Requests)

Scope rate limits exclusively to expensive server endpoints, and explicitly carve out inbound signed webhook paths (/api/webhooks/stripe, /api/webhooks/github) where bursts from a single provider IP are legitimate:

# Cloudflare WAF -> Rate Limiting Rules
# When incoming requests match:
(
  starts_with(http.request.uri.path, "/api/") or
  http.request.uri.path eq "/search"
) and not starts_with(http.request.uri.path, "/api/webhooks/") and not cf.client.bot

# Rate limit parameters (Free/Paid plan compatible):
# Characteristic: IP Address
# Requests: 60 requests per 1 minute
# Action: Block with HTTP 429 Too Many Requests (Duration: 60 seconds)

Returning a clean 429 Too Many Requests (rather than an HTML challenge page) ensures your own frontend fetch wrappers can back off gracefully if a power user clicks rapidly, while automated credential stuffers and JSON API harvesters hit an immediate ceiling of 1 req/sec before touching Vercel Fluid Compute or your database.

How do you verify bot SEO safety and cache hit ratios before closing the incident?

Run four terminal checks after deploying your caching and WAF rules: confirm /robots.txt and /llms.txt return 200 OK, verify spoofed Googlebot requests from your workstation IP get blocked (403), check that ?utm_source=... hits warm CDN cache (HIT), and confirm /api/* bursts return 429 without affecting static pages.

Execute this verification suite against production from your local machine:

# 1. Verify /robots.txt and /llms.txt serve cleanly from edge cache (Expect 200 + HIT)
curl -sI "https://example.com/robots.txt" | grep -iE "^(http|cf-cache-status|x-vercel-cache|cache-control)"
curl -sI "https://example.com/llms.txt" | grep -iE "^(http|cf-cache-status|content-type)"

# 2. Confirm query-string normalization hits warm cache on second request (Expect HIT)
curl -sI "https://example.com/guides/sample-post/?utm_source=bot_test_1" > /dev/null
curl -sI "https://example.com/guides/sample-post/?utm_source=bot_test_2&fbclid=xyz" \
  | grep -iE "^(http|cf-cache-status|x-vercel-cache)"

# 3. Test spoofed Googlebot User-Agent from non-Google IP -> Expect HTTP/2 403 Forbidden
curl -sI -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" \
  "https://example.com/" | head -n 5

# 4. Confirm normal browser UA still receives 200 OK on the exact same URL
curl -sI -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" \
  "https://example.com/" | head -n 5

Also run URL Inspection -> Test Live URL inside Google Search Console on one homepage and one deep guide URL right after enabling WAF Custom Rule 1. Because Google's live inspection fetcher originates from verified Google ASN space (cf.client.bot == true), seeing a green "URL is available to Google" confirmation proves your spoof-bot rule is live with zero SEO regression.

Model your own stack numbersCalculate your real Vercel Pro, Cloudflare Workers, and CI/CD monthly TCO

Open Calculator →

Common edge cases

Why does blocking GPTBot or OAI-SearchBot in robots.txt often fail to reduce my Vercel or AWS bill?

Polite crawlers from OpenAI, Anthropic, Google, and Perplexity obey robots.txt and crawl at modest rates, whereas the traffic responsible for 90%+ of sudden serverless compute spikes comes from unverified headless scrapers spoofing browser or Googlebot User-Agent strings that ignore robots.txt completely.

How do I block fake Googlebot scrapers in Cloudflare WAF without hurting Google Search indexing?

Use Cloudflare's verified bot field: match requests where http.user_agent contains 'Googlebot' (or 'Bingbot', 'GPTBot', 'ClaudeBot') AND not cf.client.bot, then set the action to Block. Cloudflare cryptographically and DNS-verifies real crawler IPs, so genuine search and AI bots pass untouched while spoofed Python or residential-proxy scrapers drop at the edge.

Why are my Next.js App Router pages missing CDN cache and billing Fluid Compute on every bot visit?

Calling cookies(), headers(), or reading dynamic searchParams inside a Next.js Server Component opts the entire route into per-request dynamic rendering with Cache-Control: private, no-cache, no-store. Moving personalization to client islands or edge-cached s-maxage headers stops bots from invoking server CPU on every hit.

What changed1
  • 2026-12-04: Verified against December 2026 Next.js 16 image configuration, Vercel Fluid Compute/Origin Transfer meters, and GitHub Actions macOS runner multipliers.
Sources checked4

Spotted a provider quota or SDK change since 4 Dec 2026? Send a verification note →

Related troubleshooting runbooks