req.vcl.generation

INTEGER, read-only.

Available inall subroutines.

The generation number of the currently executing VCL.

The generation number is an integer which is incorporated into the hash function Fastly uses to identify the cache location of requested objects. When a Fastly service is purged using a "purge all" operation, the generation number for that service is incremented, so that all subsequent hash calculations produce a new result. This makes existing cached objects unreachable and effectively clears the service cache.

Learn more about purging Fastly services in our purging guide.

Try it out

req.vcl.generation 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.

Prevent race conditions with purge-all and shielding

If edge and shield POPs are purged in the wrong order, stale content may get re-cached. You can prevent that.