Setting different connection timeouts based on URL path
People sometimes require different connection timeouts based on URL path due to connection time being “slow”. The documentation we have on this only covers changing the connection timeout for all URL paths by directly setting the time under First Byte within your origin settings in the UI. If this doesn’t answer your question, please see below.
Before we proceed, one thing to note is that Fastly enforces a 60 second timeout between nodes unless you’re PASSing requests in vcl_recv. If you want it to be longer than 60 seconds, you should PASS the request.
One way you can do this is by applying connection timeouts by URL path in MISS/PASS.
Say you want the URL path /admin to have a longer timeout of 600 seconds, your VCL would look like the following:
if ( req.url ~ "^/admin" ) {
set bereq.first_byte_timeout = 600s;
}
You’ll need to add this logic to VCL MISS and PASS in a snippet.
Another way you can implement this is by defining the same backend multiple times with different connection timeouts, and then use an edge dictionary to select the backend with the specific timeouts you want.
-
Thank you this was very helpful!
I am using it for Wordpress so to bypass the 60 seconds connection max limit so I used a snipped with
- NAME: wp-admin snippet miss (and one for pass so two created)
- within subroutine: miss (vcl_miss) (and the other is (pass vcl_pass))
- VCL
if ( req.url ~ "^/wp-admin" ) {
set bereq.first_byte_timeout = 600s;}
Please sign in to leave a comment.
Comments
1 comment