Available in all subroutines.

Looks up the key key in the table ID. When the key is present, its associated value will be returned. When the key is absent, a not set string value is returned.

When a third STRING argument is provided, the lookup function behaves as it would normally, except when a key is absent, the default value is returned instead.


table geoip_lang {
"US": "en-US",
"FR": "fr-FR",
"NL": "nl-NL",
if (!req.http.Accept-Language) {
set req.http.Accept-Language = table.lookup(geoip_lang, geoip.country_code, "en-US");
table extension {
"xhtml5": "xhtml",
"html5": "html",
"htm": "html",
"aif": "aiff",
"tif": "tiff",
"jpg": "jpeg",
"mpg": "mpeg",
sub vcl_recv {
# normalizing URL file extensions
declare local var.ext STRING;
# lowercase for both the table key and for the default value
set var.ext = std.tolower(req.url.ext);
set var.ext = table.lookup(extension, var.ext, var.ext);

Try it out

table.lookup is used in the following solution recipes. Recipes apply VCL to real-world use cases and can be deployed as-is, or adapted for your own service. See the full list of recipes for more inspiration.

Click RUN on a sample below to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

HTTP Basic Auth

Store username/password list in an edge dictionary, authorize user at the edge, reject requests that don't have correct credentials.

Dictionary based IP block list

Block a list of IP addresses from accessing your service and include an expiry time.

Redirect old URLs at the edge

Use a dictionary of URL mappings to serve your redirects at lightning speed.