req.backend.is_origin
BOOL, read-only.
Indicates whether the backend is a customer origin.
Shielding directs traffic from the Fastly POPs closest to the end user to the Fastly POP closest to your backend, and onward to your servers. It is therefore possible for a resource to be fetched from a backend that is another Fastly POP. When this is the case, req.backend.is_shield
will be true
and req.backend.is_origin
will be false
.
Conversely, if a request is being forwarded from Fastly to a server outside of the Fastly network, req.backend.is_shield
will be false
and req.backend.is_origin
will be true
.
Try it out
req.backend.is_origin
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.
Follow redirects at the edge
Protect clients from redirects by chasing them internally at the edge, and then return the eventual non-redirect response.
Auto retry a secondary backend
If primary backend fails, retry with a different backend without caching the failure or reducing cache efficiency.