Available inall subroutines.

Returns true if the key key has an entry in the table id.


Here's one way of implementing a simple redirect mechanism, conditional on presence in a table of URLs:

table redirects {
"/a": "/xyz",
"/b": "/abc",
sub vcl_recv {
if (table.contains(redirects, req.url.path)) {
error 800 "redirect";
sub vcl_deliver {
set resp.http.location = table.lookup(redirects, req.url.path)
+ if(req.url.qs == "", "", "?" + req.url.qs);
set resp.status = 301;

Try it out

table.contains is used in the following code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See the full list of code examples 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.

Override TTLs for path prefixes

Set TTLs at the edge based on looking up a path prefix in an edge dictionary.

Redirect old URLs at the edge

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

User contributed notes


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