Guide to VCL
About Varnish and why Fastly uses it
Varnish is the open source software Fastly commercialized with performance and capacity (among other) enhancements. Fastly's Varnish is based on Varnish 2.1 and our Varnish syntax is specifically compatible with Varnish 2.1.5. The principal configuration mechanism of Varnish software is the Varnish Configuration Language (VCL), the scripting language used to configure and add logic to Varnish caches. Varnish allows Fastly to apply changes to the cache software as it is executing. Specifically, VCL is generated, compiled, transmitted to all Fastly caches, loaded into the operating software, and activated immediately, with no waiting for maintenance windows and no server downtime.
The Fastly application generates VCL automatically per your specifications via the web interface. We allow you to create your own VCL files with specialized configurations. Your custom VCL files can be uploaded into Fastly caches and activated. You can also mix and match custom VCL and Fastly VCL, using them together at the same time. You will never lose the options on the Fastly user interface when you use custom VCL, but keep in mind that custom VCL always takes precedence over any VCL generated by the user interface. Be mindful of where your custom VCL sits in the default VCL.
Fastly's VCL Extensions
In addition, Fastly has included a number of extensions to VCL that won't be covered by any other documentation. Specifically:
|cryptographic and hashing functions||Supports Hash-based Message Authentication Code (HMAC), a message authentication code that uses a cryptographic key in conjunction with a hash function.|
|date- and time-related features||Supports the default VCL "now" variable that provides the current time as an RFC 850 formatted date (e.g., Tuesday, 29-Apr-14 08:41:55), as well as several new functions that allow you to have more flexibility when dealing with dates and times.|
|GeoIP features||Provides the ability to search a database from MaxMind.com for a given host or IP address, and return information about the country, city or Internet Service Provider (ISP) for that IP address.|
|randomness features||Supports the insertion of random strings, content cookies, and decisions into requests.|
|size-related variables||Supports reporting variables that offer insight into what happened in a request.|
|TLS and HTTP/2 variables||Supports the use of variables related to TLS and HTTP/2.|
|miscellaneous features and variables||Provides miscellaneous VCL extensions not easily grouped into other categories.|
Embedding inline C code in VCL
Currently, we don't provide embedded C access to our users. Fastly is a shared infrastructure. By allowing the use of inline C code, we could potentially give a single user the power to read, write to, or write from everything. As a result, our varnish process (i.e., files on disk, memory of the varnish user's processes) would become unprotected because inline C code opens the potential for users to do things like crash servers, steal data, or run a botnet.
We appreciate feedback from our customers. If you are interested in a feature that requires C code, please contact firstname.lastname@example.org. Our engineering team looks forward to these kinds of challenges.
Where to learn more about Varnish and VCL
The official Varnish documentation is a good place to start when looking for online information. In addition, Varnish Software, who provides commercial support for Varnish, has written a free online book.
Roberto Moutinho's book Instant Varnish Cache also provides information.