retrystorm · Learn · Interview practice · Glossary · Components

Home › Reference › Glossary › Edge function

Edge function

Code that runs at a CDN's edge locations on every request: it can answer from the edge like a CDN and still see each request.

In the lesson

Edge functions close that gap. You deploy a small function to every edge location, and it runs on every request, in the city the request came from. It can answer from a cache at the edge just as a CDN does, and still do work per request: send an event about it, check a header, choose between two answers.

In short: An edge function runs your code at the edge on every request, so it can answer like a CDN and still see each one.

Taught in Chapter 15: The Edge. Try it in the simulator: Serve the World.

More from the same chapter

  • Cache key: What a cache files each copy under, usually the URL.
  • CDN: A content delivery network: caches in cities around the world, close to users.
  • Edge and origin: The edge is a CDN location near users; the origin is your own servers behind it.
  • Origin shield: A CDN layer between the edges and the origin, so many edges missing the same file cost the origin one fetch.
  • Purge: Removing a CDN's cached copy before its TTL runs out, usually after the content changed. It takes from a fraction of a second to minutes to reach every edge, depending on the CDN.
  • Static and dynamic content: Static content is the same for everyone and caches well; dynamic content is built per user.
AI system design mock interview · About · Contact · Privacy · Terms of use