# Control when Liberator purges its object cache

You can configure Liberator to purge (remove) the contents of named directories from its cache at regular intervals. An object is only removed from the cache if no client is subscribed to it. Here’s how to configure cache purging:

You use the following three options of the [add-object](liberator-object-configuration-part-1.md#add-object) configuration item to control when Liberator purges directories from its cache:

* [purge-time](liberator-object-configuration-part-1.md#purge-time): The time when the Liberator is to start purging the objects in the directory. This time is the number of minutes after midnight (local time) on the day the Liberator was started, or if it’s greater than or equal to `1440` (24 hours), it’s the number of minutes past midnight on a Sunday.
* [purge-age](liberator-object-configuration-part-1.md#purge-age): When `purge-age` is present and isn’t zero, only objects in the directory that haven’t been updated for `purge-period` x `purge-age` minutes are candidates for removal.
* [purge-period](liberator-object-configuration-part-1.md#purge-period): The number of minutes between successive purges following the first purge at `purge-time`.

## Example 1

This configuration causes Liberator to purge all objects under the directory `/I/CHARTS` at 2am every morning, provided no clients are subscribed to the directory when the purge is attempted:

```
add-object
  name         /I/CHARTS
  type         directory
  purge-time   120
  purge-period 1440
end-object
```

Here we haven’t configured a `purge-age`, and because this option’s default value is zero, all non-subscribed objects in the directory can be purged, regardless of when they were last updated. `purge-time` is set to `120` mins, which is 2 hours after midnight, and `purge-period` is `1440` minutes, which is every 24 hours.

Here are some variants of this configuration:

* To purge the directory at midnight every day, set `purge-time` = `0` and `purge-period` = `1440` (24 hrs)
* To purge the directory at 3am and 3pm every day, set `purge-time` = `180` ( 3 hrs past midnight) and `purge-period` = `720` (12 hrs)
* To purge the directory every hour, set `purge-time` = `0` and `purge-period` = `60`

## Example 2

This example shows how to use the `purge-age` option:

```
add-object
   name /I/CHARTS
   type         directory
   purge-time   0
   purge-period 1440
   purge-age    7
end-object
```

This configuration makes Liberator purge objects under the directory `/I/CHARTS` at midnight (`purge-time` = `0`) every day (`purge-period` of `1440` mins = 24 hrs), but it only purges those objects that haven’t been updated for a week (`purge-period` x `purge-age` = `1440` x `7` mins = 7 days)

Here are some variants of the above configuration:

* If `purge-age = 1`, only objects that haven’t been updated for `1440` minutes (1 day) are purged.
* If `purge-period` = `60` (1 hour) and `purge-age` = `6`, objects not updated for 6 hours are purged hourly.

**💡 TIP**\
We recommend that you configure a daily purge of objects. Use `purge-age` to control how old particular objects should be before they’re actually purged.

## Example 3

This example shows how to configure a directory purge once a week at a specific time relative to midnight on a Sunday:

```
add-object
   name         /DIR1
   type         directory
   purge-time   8760 
   purge-period 10080
end-object
```

The purge-time of `8760` mins is 6 days and 2 hours, which is greater than 24 hrs. So the first purge starts at 6 days and 2 hours after midnight on Sunday; that is at 2 am on the following Sunday. The purge-period of `10080` mins is 7 days, so subsequent purges start at 2 am every Sunday.
