Next: Disk format, Previous: Asynchronous writing, Up: Disk cache [Contents][Index]

#### 4.3.2 Purging the on-disk cache

Polipo never removes a file in its on-disk cache, except when it finds that the instance that it represents has been superseded by a newer version. In order to keep the on-disk cache from growing without bound, it is necessary to purge it once in a while. Purging the cache typically consists in removing some files, truncating large files (see Partial instances) or moving them to off-line storage.

Polipo itself can be used to purge its on-disk cache; this is done by invoking Polipo with the `-x` flag. This can safely be done when Polipo is running (see Modifying the on-disk cache).

For a purge to be effective, it is necessary to cause Polipo to write-out its in-memory cache to disk (see Stopping). Additionally, Polipo will not necessarily notice the changed files until it attempts to access them; thus, you will want it to discard its in-memory cache after performing the purge. The safe way to perform a purge is therefore:

    $ kill -USR1 polipo-pid
    $ sleep 1
    $ polipo -x
    $ kill -USR2 polipo-pid

The behaviour of the `-x` flag is controlled by three configuration variables. The variable `diskCacheUnlinkTime` specifies the time during which an on-disk entry should remain unused before it is eligible for removal; it defaults to 32 days.

The variable `diskCacheTruncateTime` specifies the time for which an on-disk entry should remain unused before it is eligible for truncation; it defaults to 4 days and a half. The variable `diskCacheTruncateSize` specifies the size at which files are truncated after they have not been accessed for `diskCacheTruncateTime`; it defaults to 1MB.

Usually, Polipo uses a file’s modification time in order to determine whether it is old enough to be expirable. This heuristic can be disabled by setting the variable `preciseExpiry` to true.

Next: Disk format, Previous: Asynchronous writing, Up: Disk cache [Contents][Index]