Get to know advanced caching with Fastly Compute with a starter kit.
For more details about this and other starter kits for Compute, see the Fastly Documentation Hub.
As of version 3.30.1 of the Fastly Compute SDK for JavaScript, it is now possible to apply advanced caching techniques while accessing the Fastly readthrough cache.
- Modifying a request as it is forwarded to a backend
- Controlling cache behavior based on backend response
- Manipulating the response body that is stored to the cache
This starter kit gives you a starting point for calling these extension points, enabling you to understand and customize powerful caching behavior with Fastly Compute.
Note
The advanced caching features whose uses are illustrated in this starter kit are not currently supported in Fastly's local development server. Attempting to run this starter kit in the local development server may result in the following error:
HTTP caching API is not enabled.
Because advanced caching requirements vary significantly between applications, this starter kit is not designed to be deployed and run directly out of the box, unlike most Fastly Compute starter kits. Rather, it is a starting point for a Fastly Compute application code that shows how to set up the advanced caching features of the readthrough cache:
- the before-send callback function
- the after-send callback function
- the body-transform callback function
Since the code of this starter kit works with the Fastly readthrough cache, it expects a configured backend named "origin" that points to an origin server. For example, if the server is available at domain example.com
, then you'll need to create a backend on your Compute service named "origin" with the destination host set to example.com
and port 443
. Also set Override Host
to the same host value.
For details on advanced caching, see Customizing cache interaction with the backend in the developer documentation.
Please see SECURITY.md for guidance on reporting security-related issues.