- Published on
Cache Prefetching
- Authors
- Name
- Alex Lee
- @alexjoelee
Using context clues, it may not be hard to understand what cache prefetching is, "it's fetching data to fill the cache before it's requested." How does this technique work in practice?
How Caching Works
In a normal CDN scenario, edge caching works by caching common responses from the origin as users request them. This means that the first request for a particular response isn't served by the cache server, but rather the request is forwarded to the origin. Subsequent requests to the cache server are faster and aren't forwarded to the origin. This improves speed and user experience, boosts application performance, and reduces strain on an origin's resources.
One Step Further: Prefetching
Some CDN providers offer cache prefetching, a way to tell the CDN to automatically fetch files from the origin in preparation for user requests. In many cases, this can be done manually or on a set schedule, and is often used in conjunction with Cache Invalidation. Prefetching allows you to load the cache servers up with common responses, whether they are documents, pictures, or other files. This way, when users start to request the data, your origin servers aren't bogged down and the users receive a faster response.
How We Do It
For our platform, you can set up a list of assets you want us to actively prefetch. Either on a set schedule or with your automation (via webhook,) we will replace assets in our edge caches with newly-fetched assets from your origin.