Node: Purging, Next: , Previous: Asynchronous writing, Up: Disk cache



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. However, as resources are stored on disk in plain files (see Disk format), any utility that can parse the files written by Polipo can be used.

Purging the on-disk cache can be safely done when Polipo is running as long as no file is ever modified in place; in particular, it is not safe to truncate a file in-place. It is safe to unlink (remove, delete) files in the disk cache, or to add new files to the cache (in which case you should perform an exclusive open). Polipo's behaviour when invoked with the flag -x does obey these restrictions.

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 of performing 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 files 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.