Revalidate tag

Use the revalidate tag to indicate which cached content should be considered stale. The tag tells the edge servers to revalidate an object if the cached copy is older than the timestamp you specified.

Tag values

Consider this example:

<revalidate>1113551040</revalidate>
<revalidate>now</revalidate>

For the tag value, you can use:

  • The key word now, which triggers a revalidation on the next request.

  • An integer representing an epoch time. In the example above, the edge servers send the If-Modified-Sincerequest to the origin if an object was last validated before Fri Apr 15 07:44:00 2005 UTC. You can specify a time in the past, but not before the content was last changed on the origin server. Also, make sure you don't specify a future time. Otherwise, old versions of the content may persist in cache.

Epoch time

The time in the revalidatetag uses the Unix epoch time format. This time is represented as the number of seconds that have passed since 1 January 1970 00:00 UTC.

You can calculate the current epoch time with the following Unix command:

$ date +%s
1010705782

To print the Unix epoch time for a particular time string, use this command:

$ date -d 'Sat Sep 8 18:46:39 PDT 2001' +%s
999999999

📘

The example uses a date in the Pacific time zone.

That same epoch time in a different time zone:

$ date -d 'Sun Sep 9 01:46:39 UTC 2001' +%s
999999999

You can specify the time in any time zone and it will be the same on every Unix machine, provided their date settings are aligned. Unix has done the conversion from your time zone to UTC for you.

However, for clarity it's always best to express times in GMT or UTC, since this is the time zone used by edge servers and it avoids errors due to time zone conversion and daylight-saving-time changes.

Using multiple revalidate tags

You can add multiple revalidatetags to your file. However, make sure you don't have two identical matches at any level in the tree.

The following example is invalid because the match on the examplevalue appears twice at the same level:

<match:example value="a">
    <match:bar value="b">
        <revalidate>now</revalidate>
    </match:bar>
</match:example
<match:example value="a">
    <match:bar value="c">
        <revalidate>now</revalidate>
    </match:bar>
</match:example>

The valid form removes the duplication:

<match:example value="a">
    <match:bar value="b">
         <revalidate>now</revalidate>
    </match:bar>
    <match:bar value="c">
         <revalidate>now</revalidate>
    </match:bar>
</match:example>