CDN Edge Computing & Edge Functions 4 — Questions and Answers
Question 1: What is WebAssembly (Wasm) used for in edge computing environments?
- Replacing TLS for encrypted data transport
- Running code compiled from languages like Rust or C at near-native speed inside edge sandboxes (Correct answer)
- Providing a fallback when JavaScript is disabled
- Compressing HTTP response payloads at the edge
Correct answer: Running code compiled from languages like Rust or C at near-native speed inside edge sandboxes
Wasm allows high-performance, sandboxed execution of code written in systems languages, expanding the set of workloads suitable for edge functions.
Question 2: Which of the following is a key limitation of edge functions compared to traditional server-side applications?
- They cannot modify HTTP headers
- They typically have restricted CPU time limits and cannot run long-lived background processes (Correct answer)
- They cannot access TLS-encrypted traffic
- They are unable to serve static files
Correct answer: They typically have restricted CPU time limits and cannot run long-lived background processes
Edge functions have strict CPU time budgets (often milliseconds) and are not designed for long-running or stateful background workloads.
Question 3: What is 'origin shield' and how does it interact with edge functions?
- A DDoS firewall placed in front of the CDN
- A designated mid-tier PoP that consolidates cache misses from all edge nodes before hitting origin, reducing origin load (Correct answer)
- An edge function that rewrites malicious request payloads
- A CDN feature that encrypts traffic between PoPs
Correct answer: A designated mid-tier PoP that consolidates cache misses from all edge nodes before hitting origin, reducing origin load
Origin shield acts as a second caching layer between edge PoPs and the origin, so cache misses from hundreds of edges are funneled through one shield node.
Question 4: How do edge functions typically handle authentication tokens such as cookies without violating the CDN's caching model?
- By stripping cookies before caching and re-attaching or validating them using the edge function (Correct answer)
- By forwarding all cookies to origin and disabling caching entirely
- By encoding tokens in the URL path to make them cache-key-friendly
- By storing tokens in a shared cache partition keyed by user ID
Correct answer: By stripping cookies before caching and re-attaching or validating them using the edge function
A common pattern is to strip auth cookies at the edge, serve a cached response, and then use the edge function to re-inject user-specific data or validate the token before delivery.
Question 5: Which standard API do Cloudflare Workers and other edge platforms expose for making outbound HTTP calls from an edge function?
- XMLHttpRequest
- Node.js http.request()
- The Web Fetch API (fetch()) (Correct answer)
- cURL via a shell subprocess
Correct answer: The Web Fetch API (fetch())
Edge function runtimes implement the Web Fetch API (same as browsers) for making outbound HTTP requests, keeping the API surface standard and portable.
Question 6: What is cache poisoning via edge function and how is it prevented?
- Injecting malicious content into CDN cache by manipulating request headers that are inadvertently included in the cache key (Correct answer)
- Overloading the edge with requests to exhaust cache storage
- Redirecting cache writes to a competitor's CDN
- Poisoning DNS records to redirect cache lookups
Correct answer: Injecting malicious content into CDN cache by manipulating request headers that are inadvertently included in the cache key
If an edge function uses attacker-controlled headers as cache keys, an attacker can serve malicious cached responses; prevention requires strict cache key normalization.
Question 7: An edge function needs to perform image resizing. Which approach is most appropriate given edge resource constraints?
- Load a full Node.js Sharp library into the edge isolate
- Use the CDN platform's built-in image transformation service or a Wasm-compiled image library within size limits (Correct answer)
- Stream the raw image to the client and resize it in the browser
- Offload all resizing to a third-party SaaS and cache results at the edge
Correct answer: Use the CDN platform's built-in image transformation service or a Wasm-compiled image library within size limits
Edge functions have memory and bundle size limits, so either the platform's native image API or a lightweight Wasm library is the practical choice.
What is WebAssembly (Wasm) used for in edge computing environments?