Table

A table declaration creates a key-value store in VCL code. Table keys are always of type STRING, and values may be one of a number of VCL types, but must all be of the same type within the same table.

Tables may be declared using VCL, but can also be created via an API call, using the CLI, or using the web interface.

HINT: Tables created via API, CLI, or web interface are called Edge Dictionaries and are dynamic (i.e., the items in the dictionary may be changed without cloning and activating a new version of your service).

Syntax

The following examples shows the syntax of a STRING table:

table redirects {
"/old/path": "https://other.hostname/new/path",
"/another/path": "/new/path",
}

The table.contains function will return a BOOL indicating whether a specified key is in the table.

For STRING tables, the table.lookup function returns the value for a specified key, or a fallback value if the key is not present in the table.

Type variations

Table declarations support a type specifier and valid types are STRING (the default), ACL, BACKEND, BOOL, FLOAT, INTEGER, IP, and RTIME. A typed table is declared like this:

table routing_table BACKEND {
"a.example.com": b0,
"b.example.com": b1,
"c.example.com": b2,
}

The following functions return values from typed tables:

Usage

Redirects are a very common use case for tables:

Limitations

The number of items in a single table is limited to 1000 by default, but larger tables are common. If you need a larger limit than the default, get in touch with support@fastly.com and we'll be glad to assist you.

User contributed notes

BETA

Do you see an error in this page? Do have an interesting use case, example or edge case people should know about? Share your knowledge and help people who are reading this page! (Comments are moderated; for support, please contact support@fastly.com)