Home / Companies / Fastly / Blog / Post Details
Content Deep Dive

VCL Support for Parameters in Custom Subs

Blog post from Fastly

Post Details
Company
Date Published
Author
Katherine Flavel
Word Count
1,631
Language
English
Hacker News Points
-
Summary

Fastly has enhanced its Varnish Configuration Language (VCL) by introducing return values and parameters for user-defined subroutines, aligning it more closely with general-purpose programming languages. This update facilitates better code reuse and abstraction, addressing previous limitations where values had to be passed and returned through headers. The new syntax allows for a wider range of data types, including numeric types, ACLs, and backends, providing more flexibility in passing and returning values. Examples illustrate the new capabilities, such as concatenating strings, conducting A/B testing, selecting ACLs based on authentication, anonymizing IP addresses, and generating regional indicator symbols for country codes. These improvements make VCL syntax cleaner, tidier, and more reusable, encouraging developers to simplify and share their code within the Fastly Connect community.