CDN Edge Computing & Edge Functions 2 — Questions and Answers
Question 1: What is the primary advantage of running A/B testing logic at the edge rather than at the origin server?
- It eliminates the need for a control group
- It reduces latency by making routing decisions closer to the user (Correct answer)
- It allows A/B tests to run without any JavaScript
- It automatically selects the winning variant after 24 hours
Correct answer: It reduces latency by making routing decisions closer to the user
Running A/B test routing at the edge avoids an extra round-trip to the origin, reducing latency for every experiment assignment.
Question 2: Which HTTP header is most commonly inspected by an edge function to serve device-specific content (e.g., mobile vs. desktop)?
- X-Forwarded-For
- Accept-Encoding
- User-Agent (Correct answer)
- Cache-Control
Correct answer: User-Agent
The User-Agent header identifies the client browser and device type, enabling the edge to route or transform responses accordingly.
Question 3: An edge function needs to share state across multiple requests from different users. What is the recommended approach given that edge workers are stateless?
- Store state in a global JavaScript variable
- Use an edge-accessible key-value store such as Cloudflare KV or Durable Objects (Correct answer)
- Write state to the local filesystem of the edge node
- Pass state as a cookie signed by the origin
Correct answer: Use an edge-accessible key-value store such as Cloudflare KV or Durable Objects
Edge workers are stateless by design, so distributed key-value stores or durable objects provided by the platform are the standard way to persist state at the edge.
Question 4: What happens to an edge function's in-memory variables between two separate HTTP requests handled by the same edge node?
- They persist indefinitely until the node restarts
- They persist only for the lifetime of that request; the next request starts fresh (Correct answer)
- They are synchronized across all edge nodes automatically
- They are stored in L2 cache for 60 seconds
Correct answer: They persist only for the lifetime of that request; the next request starts fresh
Edge functions follow a request-scoped execution model, so in-memory state does not survive across separate requests.
Question 5: Which of the following best describes 'cold start' in the context of edge functions?
- The time taken to establish a TLS session with the client
- The latency incurred when a function instance is initialized for the first time or after being idle (Correct answer)
- The delay caused by DNS resolution at the edge
- The time needed to warm up the CDN cache after a purge
Correct answer: The latency incurred when a function instance is initialized for the first time or after being idle
A cold start is the initialization overhead paid when a new function isolate is spun up, adding latency to the first request handled by that instance.
Question 6: An edge function returns a subrequest to the origin. How is this typically different from the original client request?
- It always uses HTTP/1.1 regardless of the client protocol
- It is an internal request made by the edge worker to fetch data or assets needed to construct the response (Correct answer)
- It bypasses TLS encryption for performance
- It is sent to a random origin server without load balancing
Correct answer: It is an internal request made by the edge worker to fetch data or assets needed to construct the response
A subrequest is a programmatic fetch initiated by the edge function to retrieve upstream data while the original client connection remains open.
Question 7: What is 'request collapsing' (also called 'request coalescing') in an edge computing context?
- Merging multiple client TCP connections into one for efficiency
- Combining identical concurrent cache-miss requests into a single upstream fetch (Correct answer)
- Compressing the HTTP request body before sending to origin
- Batching multiple HTTP responses into a single stream
Correct answer: Combining identical concurrent cache-miss requests into a single upstream fetch
Request collapsing prevents cache stampedes by queuing duplicate concurrent requests and serving them all from one upstream fetch.
What is the primary advantage of running A/B testing logic at the edge rather than at the origin server?