Last updated March 21, 2017
If you are having problems using conditions, here are some common mistakes to look for:
- Don't put the
if ()statement in the Apply if field of the condition window. The actual if statement is implied. You only need to type an evaluated expression. For example:
req.url ~ "^/special/".
- Don't use the
!~(inverse regex match) to build regular expressions that exclude particular URLs. For example, if you want to apply something to all URLs except those that start with
/admin, the condition for this is
req.url !~ "^/admin"and is entered in the Apply If field. An alternative to this expression would be
!(req.url ~ "^/admin").
You can edit your condition that are listed on the same page as your configurations. Depending on the condition, you can edit the cache, request, responses, and header conditions.
For example, if you have a cache condition that was being applied to a response, you would edit that condition in your service's configuration as follows:
- Log in to the Fastly web interface and click the Configure link.
- From the service menu, select the appropriate service.
- Click the Configuration button and then select Clone active. The service version page appears.
Click the desired tab that has the condition that you want to edit. For example, click the Settings tab and find the desired condition.
Click the IF statement link of the condition (for example, click IF Article page). For this example, the Edit this request condition window appears.
- Make your edits and click Save.
The following links provide additional information useful when working with and troubleshooting conditions:
- Fastly Help Guides provides basic editing information when using the web interface.
- Tizag Perl tutorial explains basic C-style logical expression syntax (e.g., basic logic, operators such as &&, precedence) that users need to be familiar with when creating conditions.
- Varnish-Cache.org documentation explains different set of VCL variables that a condition can use to determine if an object applies.
- Varnish Cache documentation on variables describes variables that are used to craft conditions.