Banjo not included


A very useful service that Fastly provides is called Fiddle, available at https://fiddle.fastlydemo.net

Conceptually, Fiddle is just like JSFiddle or anything else, except for VCL. It allows you to write simple VCL snippets, even if you don't have a Fastly account, and watch how the HTTP request flows through the caching system above.

As an example, go ahead and open Fiddle in a new browser tab. On the left, open the dropdown named DELIVER, and type in the following code:

set resp.http.Cool-Testing-Header = "hello world!";

The DELIVER block is run before any response gets returned to the client, in all code paths. This example sets a new HTTP header on all responses delivered to a client. Ultimately, it should look like this:

A sample Fiddle that adds HTTP headers to all responses

A sample Fiddle that adds HTTP headers to all responses

Click RUN on the top-right. After a few seconds, the results of the GET request to https://httpbin.org should be displayed. On the right, you can see how the Cool-Testing-Header was added to the response, in the DELIVER phase:

The original HTTP request to httpbin.org, followed by the original HTTP response.

The original HTTP request to httpbin.org, followed by the original HTTP response.

The final HTTP response delivered to a client. The  was added directly by VCL in the deliver phase, but is otherwise unmodified.

The final HTTP response delivered to a client. The cool-testing-header was added directly by VCL in the deliver phase, but is otherwise unmodified.

A sketch of cache.nixos.org using Fiddle

As a bonus, the Fiddle below contains a replica of the new beta cache configuration, written entirely in VCL. It has detailed comments, several example HTTP requests, configuration options, object TTLs, and tests to ensure the VCL works right.

<aside> 💡 NOTE: This configuration is not an exact 100% perfect replication of the upstream configuration — just a rough one. The upstream configuration will have several extra operator options, as well as logging, configured. But this example below is a very good starting point to understand the configuration in general.

</aside>

You can find the Fiddle, along with several example requests and configuration options, here:

https://fiddle.fastlydemo.net/fiddle/25e61abd