Path matches

Use the match tags, sometimes referred to as URL component matches, to specify the URL path to the directory with objects you want to revalidate. The tags create nodes in the metadata file and help to efficiently apply these metadata to requests.

Match: recursive-dirs

Use recursive-dirs to match the specified directory and all its subdirectories. The syntax for this match is:

<match:recursive-dirs value=*dir* nocase="off" include-path-params="off">
</match:recursive-dirs>
  • The valueattribute is the directory name without the leading or following slash /.

  • The nocaseboolean attribute specifies whether the match is be case-sensitive. By default set to off.

  • The include-path-paramsboolean attribute specifies whether to include the path parameters when matching on a path component. By default set to offand ignores the path parameter during the comparison.

recursive-dirsmatches a single component of the URI path. Make sure you don't combine path components to match a longer portion of the URI path. The following syntax is not supported:

<match:recursive-dirs value="images/borders">

Although the match value is a single component of the URI path, this doesn't mean that the component can exist anywhere in the URI and result in a match. Check this more complete example, where the match tag <match:recursive-dirs value="images">is at the root directory.

<eccu>
    <match:recursive-dirs value="images">
        <revalidate>1046581729</revalidate>
    </match:recursive-dirs>
<eccu>

This match applies to any files that match the URI paths:

www.example.com/images/
www.example.com/images/*/
www.example.com/images/*/*/

Note that it does not apply the revalidatetag to:

www.example.com/electronics/images/

You can include another subdirectory in a separate tag:

<match:recursive-dirs value="images">
    <match:recursive-dirs value="borders">
         <revalidate>1046581729</revalidate>
    </match:recursive-dirs>
</match:recursive-dirs>

This example applies the revalidatetag to all files that match the URI path:

www.example.com/images/borders/
www.example.com/images/borders/*/...

If you don't want to match recursively, pair this match with a this-dirmatch.

Match: sub-dirs-only

Use sub-dirs-onlyto match all directories nested within the current directory, but not the current directory. In most cases, you first declare the directory in a separate recursive-dirsmatch. The exception is when you mean to match on any directory below the root directory. The syntax for this path match is:

<match:sub-dirs-only value="Sub-directories Only">
</match:sub-dirs-only>

The following metadata example sets revalidation for all files in any subdirectory of the imagesdirectory, but not the imagesdirectory itself.

<match:recursive-dirs name="images">
    <match:sub-dirs-only" value="Sub-directories Only>
         <revalidate>1046581729</revalidate>
    </match:recursive-dirs>
</match:recursive-dirs>

It is also possible, though not recommended, to nest sub-dirs-onlytags within each other to specify a path that contains no specific component names.

Specifically, you could match any files in directories three levels deep and below, such as these:

www.example.com/anydir/anydir2/anydir3/
www.example.com/images/borders/specials/

and apply revalidatewith the following metadata:

<match:sub-dirs-only value="Sub-directories Only">
    <match:sub-dirs-only value="Sub-directories Only">
         <match:sub-dirs-only value="Sub-directories Only">
              <revalidate>1046581729</revalidate>
         </match:sub-dirs-only>
    </match:sub-dirs-only>
</match:sub-dirs-only>

None of the directory components was specified by name. In this sense, sub-dirs-onlymatches can be interpreted as *.

Match: this-dir

Use this-dirto restrict the application of metadata to the current path component.

The syntax for this path match is:

<match:this-dir value="This Directory Only">
</match:this-dir>

The following metadata example sets revalidation for the imagesdirectory, but not for any subdirectory of the imagesdirectory.

<match:recursive-dirs value="images">
    <match:this-dir value="This Directory Only">
         <revalidate>1046581729</revalidate>
    </match:this-dir>
</match:recursive-dirs>

Match: filename

To match a specific file within a current directory, use this syntax:

<match:filename value=*file.ext* nocase="off">
</match:filename>
  • The valueattribute takes a string that is the exact file name to match.

  • The nocaseboolean attribute specifies whether the match is be case-sensitive. By default set to off.

The following metadata example matches the index.htmlfile in the root directory of a domain.

<match:this-dir value="This Directory Only">
    <match:filename value="index.html">
         <revalidate>1046581729</revalidate>
    </match:filename>
</match:this-dir>

You can match the default file within the current directory using a special value for the filenamematch:

<match:filename value="No File Specified">
</match:filename>

No File Specifiedvalue instructs the edge server to apply the metadata to whatever file the origin server delivers as the default if the directory were accessed without specifying a file. This is handy because not all default files are .html.

Match logic

Make sure you create the match logic carefully. Don't nest URL component matches within any other match type. URL matches must be nested within one another in an unbroken fashion to form the URL path in its proper order. For example, you can't nest a recursive-dirs match inside a cookie match, because the cookie is not a component of the URL. List the components in the correct order. For example, you can't enclose a recursive-dirsmatch within a filenamematch, because the file name is always last in the URL.