

In “How to solve anything” parts 1 and 2, we outlined how to use Varnish Configuration Language (VCL) to address some of your more challenging problems. In this post, we’ll discuss how Andrew Betts of the Financial Times uses advanced VCL to securely cache and serve authenticated and authorized content, and set up feature flags.

In “How to solve anything, part 1,” we discussed Andrew Betts’ clever tips for using Fastly’s Custom Varnish Configuration Language (VCL) to collect data at the edge. In this post, we’ll look at how Nikkei uses VCL to deal with a service-oriented architecture as well as write synthetic responses with non-ASCII characters.


Before diving into CORS (Cross-origin resource sharing), I need to mention JSONP, which is the other solution to getting data from a different “Origin.” In Using ESI, Part 2: Leveraging VCL and ESI to Use JSONP, Simon explains what JSONP is, and how to cache it with Fastly, using one Fastly specific feature, req.topurl. Now, with Varnish 4.1, req.top.url (note the extra period) is available, and it allows you to do the same thing with vanilla Varnish.








There's a Fastly module available called "boltsort" which allows you to easily sort the parameters in the query string, so that you will always end up with the same URL, no matter what order the consumer of your API placed them in.







