LOG IN SIGN UP
Documentation

Troubleshooting conditions

  Last updated September 21, 2018

If you are having problems using conditions, here are some common things to look for.

Check the Apply if field for if statements

Most problems with conditions occur in the Apply if parameter because it uses logical expressions to represent actual VCL variables that specify when a condition should be applied to a configuration object. If you are having problems using conditions, start by checking to see if you've put an if () statement in the wrong place. A condition's if statement is implied and doesn't need to be placed in the Apply if field of the condition window. You only need to type an evaluated expression (e.g., req.url ~ "^/special/").

Check the construction of inverse regex matches

Consider if inverse regular expression (regex) matching might be the issue, especially if you're using it to exclude a particular URL in your condition. When using the !~ (inverse regex match) to build expressions that exclude particular URLs, be thoughtful when also using the || or && operators and multiple patterns.

For example, if you want to apply something to all URLs except those that start with /admin, the condition you'd enter into the Apply if field would be req.url !~ "^/admin". If you also wanted to exclude URLs starting with /internal, that expression would be !(req.url ~ "^/admin" || req.url ~ "^/internal").

Check for general regex formatting mistakes

Consider the following general regex issues that may have caused trouble:

Our cheatsheet provides additional examples of using VCL with regular expressions.


Back to Top