Integration guide
Prerendering on Akamai EdgeWorkers
Akamai EdgeWorkers run JavaScript at the Akamai edge, integrated with Property Manager rules and Bot Manager. For enterprise sites already on Akamai, this is the natural place to add prerendering — no new vendor, no new operational surface.
Setup overview
Deploy an EdgeWorker on the request event. Classify the user-agent (using Bot Manager scores if available), rewrite bot requests to a prerender source via Property Manager origin selection or direct sub-request.
Working snippet
// EdgeWorker main.js
import { logger } from 'log'
const BOT_UA = /Googlebot|OAI-SearchBot|PerplexityBot|ClaudeBot|GPTBot|Bingbot/i
export function onClientRequest(request) {
const ua = request.getHeader('User-Agent')?.[0] ?? ''
if (!BOT_UA.test(ua)) return
// Akamai Bot Manager classification (if available)
const botScore = request.getVariable('AKAMAI_BOT_SCORE')
// Route bot requests to the prerender origin defined in Property Manager
request.route({
origin: 'prerender-origin',
path: `/snapshots${request.path}`,
headers: { 'X-Original-UA': ua },
})
logger.log(`Routed bot ${ua.slice(0, 30)} score=${botScore}`)
}Decision criteria
Fits when
- Site is already on Akamai with EdgeWorkers enabled.
- You have Bot Manager for sophisticated classification beyond user-agent.
- Compliance requires keeping all edge logic on Akamai.
Decision criteria
Avoid when
- EdgeWorkers add cost without offsetting indexation gain at your traffic volume.
- You can run the same logic on Cloudflare or Vercel for less.
Common pitfalls
Watch for these on first rollout
EdgeWorker quota and resource tier
EdgeWorkers have CPU and memory quotas per tier. The bot-routing logic is light, but combining it with other workers can exhaust the budget. Monitor execution metrics in Akamai Control Center.
Property Manager rules conflicting with worker routing
EdgeWorker route() decisions can be overridden by upstream Property Manager rules. Verify that origin selection happens at the EdgeWorker level, not earlier in the rule pipeline.
Bot Manager false positives blocking real crawlers
Aggressive Bot Manager scores can flag Googlebot or Bingbot as suspicious. Combine Bot Score with verified-bot allowlists for major crawlers to avoid accidentally blocking legitimate fetches.
FAQ
Platform-specific questions
What is the EdgeWorker resource tier I should target?
Dynamic Compute tier supports the bot-routing pattern with comfortable margin (128 KB code, 5 ms CPU, 30 MB memory). Free tier is too constrained for production prerender routing — limits will be hit under crawl traffic spikes.
Does Bot Manager replace or complement EdgeWorker logic?
Complements. Bot Manager classifies traffic and exposes a score via `pmuser_*` headers. The EdgeWorker reads that score plus its own user-agent + IP verification to make the final route decision. Both signals together are more reliable than either alone.
How do I roll out incrementally without breaking existing properties?
EdgeWorkers attach to Property Manager rules with a percentage-based traffic match. Start at 1% of bot traffic, monitor `pmuser_x_prerender_decision` log fields for 48 hours, then ramp to 10% → 50% → 100% with rollback on error-rate alerts.
Last updated:
Platform documentation
Authoritative references
Related deep-dives
Want this scoped to your stack?
Generic snippets are useful for orientation; the actual integration needs your routes, your bot traffic mix, your cache strategy. The scoping call is 30 minutes — bring the platform constraints.
Other platforms
Vercel
Add a prerendering layer to a Vercel-hosted Next.js or SPA without leaving the Vercel runtime — Edge Middleware, Edge Functions, or external prerender service.
Cloudflare
Use Cloudflare Workers to detect crawlers at the edge and route them to a prerendering source — typically the cleanest setup for SPAs and JAMstack sites.
AWS (CloudFront + Lambda@Edge)
Run prerender bot detection at CloudFront edge using Lambda@Edge — fits sites already on AWS that want native AWS infrastructure end-to-end.