40+ Fastly Interview Questions and Answers (2027)
42 Fastly interview questions with answers: VCL lifecycle, TTLs, cache keys, surrogate-key and soft purge, shielding, Compute, CLI and real scenarios.
Fastly interviews test how well you understand edge caching: how a request moves through VCL subroutines, how TTLs and cache keys are set, how surrogate-key and soft purges work, how shielding protects the origin, and when to use Fastly Compute instead of VCL. This page has 42 numbered questions with direct answers, grouped by level, plus scenarios.
Facts were checked against Fastly's documentation in November 2026. If you want a study schedule, use the Fastly interview preparation plan; for pure Compute and WebAssembly topics, see Fastly Compute and edge questions.
Key takeaways
- Fastly offers two programming models: VCL for CDN services and Compute for WebAssembly programs written in Rust, JavaScript, Go or C++.
- The VCL lifecycle runs
vcl_recv,vcl_hash, thenvcl_hit,vcl_missorvcl_pass, thenvcl_fetch,vcl_deliverandvcl_log, withvcl_errorfor synthetic responses. - Surrogate keys let you purge every object tagged with a key in one call; a soft purge marks objects stale instead of removing them.
- Shielding funnels misses through one shield POP, cutting origin load, but edge code can run twice.
- Interviewers care about debugging: reading cache headers, explaining a low hit ratio and fixing a broken purge.
VCL lifecycle quick reference
| Subroutine | When it runs | Typical use |
|---|---|---|
vcl_recv | Request arrives | Normalise URL, choose backend, decide lookup or pass |
vcl_hash | Building the cache key | Add or remove key components |
vcl_hit | Object found in cache | Deliver, or handle stale objects |
vcl_miss | Object not in cache | Adjust the backend request |
vcl_pass | Request bypasses cache | Adjust uncached backend requests |
vcl_fetch | Origin response received | Set TTL, surrogate keys, decide cacheability |
vcl_error | Error or synthetic response | Custom error pages, redirects at the edge |
vcl_deliver | Before response leaves | Add or strip client headers |
vcl_log | After delivery | Send logs to endpoints |
Fundamentals (questions 1 to 14)
1. What is Fastly?
Fastly is an edge cloud platform: a CDN with programmable edge logic, security products and a serverless WebAssembly runtime called Compute. Traffic is served from points of presence (POPs) close to users, and requests go to your origin only when the edge cannot answer.
2. What is a Fastly service?
A service is the unit of configuration: domains, backends, caching rules, logging and either VCL or a Compute package. Services are versioned; you edit a draft version and activate it.
3. What is a backend?
The origin server Fastly fetches from on a miss or pass, such as a load balancer or an object storage bucket. You can define several backends and choose one in vcl_recv.
4. What is VCL?
Varnish Configuration Language. Fastly uses its own dialect of VCL to let you control request handling at each stage of the lifecycle in CDN services.
5. What is the difference between custom VCL and VCL snippets?
Custom VCL replaces the generated VCL with your own full file and must include Fastly's macros in each subroutine. Snippets are short blocks inserted into the generated VCL for targeted changes. Snippets suit small changes; custom VCL suits complex configurations kept in one file.
6. What does "pass" mean?
The request bypasses the cache and goes to the backend, and the response is not stored. You return pass from vcl_recv or vcl_miss, typically for personalised or authenticated content.
7. How is the TTL of an object decided?
From origin headers such as Surrogate-Control, Cache-Control and Expires, unless you override it in vcl_fetch by setting beresp.ttl.
8. Why use Surrogate-Control instead of Cache-Control?
Surrogate-Control is meant for the CDN, so you can cache at the edge for a long time while telling browsers, through Cache-Control, to cache briefly or not at all.
9. What is a cache key?
The identifier used to look up an object, by default built from the URL and host. Adding needless components such as tracking parameters splits the cache and lowers the hit ratio.
10. What does stale-while-revalidate do?
Within that window Fastly returns the stale object immediately and revalidates with the backend asynchronously, so users do not wait on the origin.
11. What does stale-if-error do?
Fastly tries the backend; if the fetch fails with a network error, it serves the stale copy instead of an error.
12. What is purging?
Removing or invalidating cached content before its TTL expires, so changes at the origin show at the edge. Fastly supports URL purge, surrogate key purge and purge all.
13. What is a surrogate key?
A tag added to a response, usually through the Surrogate-Key header from the origin or set in VCL. One purge by key removes every object with that tag, for example all pages showing product 123.
14. What is the difference between a soft purge and a hard purge?
A hard purge makes objects unusable, so the next request must fetch from origin. A soft purge marks them stale; the next request can get the stale copy while Fastly fetches a fresh one. Soft purge works for URL and surrogate key purges; purge all is always hard.
Intermediate (questions 15 to 30)
15. How do you purge from the command line?
With the Fastly CLI fastly service purge command, using --url for one URL, --key for a surrogate key, --file for a list of keys, --all for the whole service and --soft to soft purge.
fastly service purge --key product-123 --soft --service-id SERVICE_ID
16. Why can a purge followed by a write show old content?
Fastly's documentation notes purges are asynchronous. If you purge before the origin write completes, a request can re-cache the old version. Purge after the write commits.
17. What is shielding?
Routing misses from all POPs through one designated shield POP before the origin. Fewer requests reach the origin and the shield's cache serves objects other POPs already requested.
18. What are the caveats of shielding?
Edge code may run twice, once at the edge and once at the shield, so client-facing changes should run only at the edge POP. Cache hit ratio can look lower because an edge miss followed by a shield hit counts as one of each. The shield sees the edge POP's IP, so use Fastly-Client-IP for the real client.
19. Why might changing the Host header break a shielded service?
Changing Host at the edge can make the shield reject the request. Fastly recommends using the backend's override host setting instead.
20. How do you see whether a response was a hit?
Check the X-Cache response header (HIT or MISS). Real-time stats and logs show hit ratio across the service.
21. How do you normalise requests to raise hit ratio?
In vcl_recv, strip marketing query parameters, sort query strings, lower-case where safe and reduce Vary on headers with many values.
22. Why is Vary: User-Agent a problem?
Each distinct user agent string creates a separate cache variant, so hit ratio drops sharply. Normalise to a device class header and vary on that instead.
23. How do you serve a custom error page at the edge?
Trigger an error in VCL and build a synthetic response in vcl_error with the status, headers and body you want.
24. How do you route by path to different backends?
In vcl_recv, set req.backend based on req.url, for example sending /api/ to an API origin and everything else to a static origin.
25. How do you send logs from Fastly?
Configure a logging endpoint (object storage, a log platform, syslog and so on) and a log format. Logging runs in vcl_log, after delivery, so it does not slow the response.
26. How do you manage Fastly configuration as code?
Use the Fastly Terraform provider or the Fastly CLI in a pipeline. Keep VCL and snippets in Git, review changes, apply to a draft version and activate after tests.
27. How do you roll back a bad change?
Services are versioned, so activate the previous known-good version. That is one reason to never edit the active version directly.
28. What is Fastly Compute?
Fastly's serverless platform that runs WebAssembly programs at the edge. Supported SDK languages are Rust, JavaScript, Go and C++; the C++ SDK lacks some features available in the others.
29. When would you choose Compute over VCL?
When logic needs a general-purpose language: complex request composition, custom auth token validation, calling several backends or reusing libraries. VCL remains simpler for cache rules and header changes.
30. How do you build and deploy a Compute service?
Create a project with the Fastly CLI, write code with the SDK, then build and publish:
fastly compute init
fastly compute serve # local testing
fastly compute publish # build and deploy to the service
Advanced (questions 31 to 36)
31. How do you design surrogate keys for a large site?
Tag each response with keys for every entity it shows: the page itself, each product, category and template. When product 123 changes, purge product-123 only.
32. How do you protect the origin during a traffic spike?
Turn on shielding, use long edge TTLs with surrogate key purging, enable stale-while-revalidate and stale-if-error.
33. How do you cache content that varies by login state?
Pass requests with session cookies for personalised pages, or split the page so the shared shell is cached and personal parts are fetched separately. Never cache responses carrying Set-Cookie for one user.
34. Which security features does Fastly offer?
Fastly sells security products alongside delivery. Interviewers mostly want to hear how you would restrict access and limit abuse at the edge, for example with Compute ACLs or VCL logic, and how you confirm what your account has enabled. Check your contract for which features are enabled.
35. How do you test VCL changes safely?
Validate the draft version, deploy to a staging service or a test domain, run automated requests that check cache headers and responses, then activate. Keep rollback to the previous version ready.
36. How does Fastly fit into CI/CD?
The pipeline deploys the application, then purges affected surrogate keys. Infrastructure changes to the service go through Terraform or the CLI with review. Compute packages are built and published as pipeline artifacts.
Scenarios (questions 37 to 42)
37. Hit ratio dropped from high to low after a release. What do you check?
Look for new query parameters, cookies or Vary headers added by the release; check whether origin responses now carry Cache-Control: private or Set-Cookie; compare cache keys in logs before and after.
38. Users still see old content after a purge.
Confirm the purge targeted the right service and key, that the response actually carried that surrogate key, that the browser is not caching due to Cache-Control, and that the purge did not run before the origin write finished.
39. The origin is overloaded although the CDN is in front.
Check pass rate, TTLs, whether shielding is on for that backend, and whether many POPs miss at once on popular objects. Raise TTLs with key-based purging and enable shielding.
40. A shielded service returns 500 errors for some requests.
Check whether VCL changes the Host header at the edge; move the change to the backend override host. Also check logic that runs twice at edge and shield.
41. You need a redirect for 10,000 old URLs.
Keep the mappings as data that the edge code looks up, then return a synthetic redirect from VCL or Compute. Thousands of if statements are slow to review and easy to break.
42. An outage at the origin is coming. How do you reduce impact?
Increase stale-if-error windows ahead of time, make sure critical pages are cached, prepare a maintenance page in vcl_error and confirm monitoring on 5xx rates at the edge.
How to practise
- Create a free Fastly account and put a service in front of a small static origin.
- Add surrogate keys at the origin, purge by key and soft purge, and watch
X-Cache. - Enable shielding and compare origin request counts.
- Build a small Compute app with the CLI and run it locally.
- Manage the service with Terraform and roll back a version.
Compare CDN concepts across vendors with our Cloudflare questions and Akamai questions, and read why edge DevOps matters. Scenario practice continues in scenario-based Fastly questions. Pipelines, Terraform and caching are part of our DevOps course, taught in Kharadi, Pune and live online.
Frequently asked questions
What is asked in a Fastly interview?
The VCL lifecycle, TTLs and cache keys, purging with surrogate keys, shielding, Compute versus VCL, logging, configuration as code and debugging low hit ratios.
What languages does Fastly Compute support?
Fastly documents SDKs for Rust, JavaScript, Go and C++. Code compiles to WebAssembly and runs at the edge.
What is a surrogate key in Fastly?
A tag on cached responses. Purging the key removes or invalidates every object carrying it in one operation.
What is a soft purge?
A purge that marks objects stale instead of removing them, so the next request can be served from the stale copy while Fastly fetches a fresh one.
What does shielding do?
It sends misses from all POPs through one shield POP, which reduces requests to the origin and increases the chance of a cache hit.
Which VCL subroutine sets the TTL?
vcl_fetch, by setting beresp.ttl after the origin response arrives.
How do I purge with the Fastly CLI?
Use fastly service purge with --url, --key, --file or --all, and add --soft for a soft purge.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0