LOG IN SIGN UP
Documentation

Checking multiple backends for a single request

Using a restart is a good option to check multiple backends for a single request. This can be created using a cache setting rule and request headers.

Create a new cache setting rule

Follow these steps to create a cache restart within vcl_fetch.

  1. Log in to the Fastly web interface and click the Configure link.
  2. From the service menu, select the appropriate service.
  3. Click the Edit configuration button and then select Clone active. The service version page appears.
  4. Click the Settings tab. The Settings page appears.
  5. Click the Create cache setting button. The Create a new cache setting page appears.

    return restart in the Create a new cache settings page

  6. Fill out the Create a new cache setting fields as follows:

    • In the TTL (seconds) field, type 0.
    • From the Action menu, select Restart processing.
    • In the Stale TTL (seconds) field, type 0.
    • In the Description field, type Return Restart (or any meaningful, preferred name).
  7. Click the Create button. The new cache setting appears on the Settings page.

  8. On the Settings page, click the Attach a condition link next to the cache setting you just created. The Create a new cache condition window appears.

    a request restart condition

  9. Fill out the Create a new cache condition fields as follows:

    • Leave the Type menu set to Cache.
    • In the Name field, type Restart Request (or any meaningful, preferred name).
    • In the Apply if field, type beresp.status != 200 && beresp.status != 304.
  10. Click the Save and apply to button to create the condition.

Create new request headers

Follow these steps to create a request header within vcl_recv.

  1. Click the Content tab. The Content page appears.
  2. Click the Create header button. The Create a new header page appears.

    a new header that creates fastly shielding

  3. Fill out the Create a new header fields as follows:

    • From the Type menu, select Request, and from the Action menu, select Set.
    • In the Destination field, type http.Fastly-Force-Shield.
    • In the Source field, type "yes".
    • From the Ignore if set menu, select No.
    • In the Priority field, type 10.
    • In the Description field, type Fastly Internal Shielding (or any meaningful, preferred name).
  4. Click the Create button. The new header appears on the Content page.

  5. Click the Create header button to create another header to switch to the next backend. The Create a new header page appears.

    a new header to switch to the second origin server

  6. Fill out the Create a new header fields as follows:

    • From the Type menu, select Request, and from the Action menu, select Set.
    • In the Destination field, type backend.
    • In the Source field, type Second_Backend (this should match the name of your other backend).
    • From the Ignore if set menu, select No.
    • In the Priority field, type 11.
    • In the Description field, type Second Backend (or any meaningful, preferred name).
  7. Click the Create button. The new header appears on the Content page.

Create new header conditions

Follow these steps to create conditions for the headers.

  1. On the Content page, click the Attach a condition link next to one of the headers you just created. The Create a new request condition window appears.

    a request restart header condition rule

  2. Fill out the Create a new request condition fields as follows:

    • Leave the Type menu set to Request.
    • In the Name field, type Req.request (or any meaningful, preferred name).
    • In the Apply if field, type req.restarts == 1.
  3. Click Save and apply to. The condition appears on the Content page.

  4. Repeat steps 1-3 for the other header.

  5. Click the Activate button to deploy your configuration changes.


Back to Top