fastly.ff.visits_this_service

INTEGER, read-only.

Available inall subroutines.

The number of previous Fastly servers that have seen the current request in the context of the current service configuration.

This can be seen as an indication of how "deep" the request has gone within the Fastly network. By default, Fastly services perform clustering, which transfers control of the request from one cache server to another after the cache key has been calculated. As a result, it is common for this value to be 0 in vcl_recv, but 1 in vcl_miss, vcl_hit, and vcl_fetch, returning to 0 in vcl_deliver.

For services that have shielding enabled, the value may be as high as 3 in vcl_fetch at the shield data center.

This value is derived from the Fastly-FF request header and should be used in preference to reading the header directly.

Example

In general, fastly.ff.visits_this_service is used to check that the current node is the outermost one, allowing for initial processing to take place on a request or for final processing to take place on a response. For example, in vcl_deliver, it can be used to add a browser-only caching policy:

if (fastly.ff.visits_this_service == 0) {
set resp.http.Cache-Control = "private, no-store";
}

Try it out

fastly.ff.visits_this_service 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.

Geofence / block access to content by region

Group countries to cache content by custom regions or reject requests from some regions entirely.

Create image transform presets

Use custom, predefined classnames like large, medium, small, teaser, thumb, or article to control Fastly Image Optimizer and optionally prevent end-user access to native properties like 'width'.