Available inall subroutines.

Returns a hash value of the string key, using seed, and returning a number between from and to, inclusive.

The underlying hash function might not offer cryptographic properties or collision resistance guarantees.


declare local var.hurl INTEGER;
set var.hurl = fastly.hash(req.url, 0, 0, 1023);

Try it out

fastly.hash 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.

Enable features gradually

Avoid a huge inrush of traffic to origin caused by gradually applying changes that affect the cache key, like segmented caching, over hours or days.

User contributed notes


Do you see an error in this page? Do you 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 Fastly support)