HTCACHECLEAN(8)

๐Ÿ“ฆ
version 2.4.69 ยท 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian bookworm, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu stonking

๐Ÿ’– HTCACHECLEAN(8) ๐Ÿ’–

okay bestie, this is htcacheclean โ€” the section 8 (system admin) manual page, and she's literally the girl who keeps your disk cache from eating your whole hard drive. no cap. let's get into it โœจ


๐ŸŒธ NAME ๐ŸŒธ

htcacheclean โ€” Clean up the disk cache ๐Ÿงนโœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

htcacheclean [ -D ] [ -v ] [ -t ] [ -r ] [ -n ] [ -Rround ] -ppath [
-llimit ] [ -Llimit ]

htcacheclean [ -n ] [ -t ] [ -i ] [ -Ppidfile ] [ -Rround ] -dinterval
-ppath [ -llimit ] [ -Llimit ]

htcacheclean [ -v ] [ -Rround ] -ppath [ -a ] [ -A ]

htcacheclean [ -D ] [ -v ] [ -t ] [ -Rround ] -ppath url

๐Ÿฆ‹ SUMMARY ๐Ÿฆ‹

so htcacheclean exists to keep the size of mod_cache_disk's storage inside a given size limit, or inside a limit on the inodes in use. she can run manually or in daemon mode, your call ๐Ÿ’…

when she's in daemon mode, she sleeps in the background and checks the cache directory at regular intervals for cached content that needs to go ๐Ÿ—‘๏ธ

and the way you stop the daemon cleanly? just send her a TERM or INT signal. she'll wrap it up, no drama ๐Ÿซถ

when you run her manually, it's a once-off check of the cache directory for cached content to be removed. and if you specify one or more URLs, each URL gets deleted from the cache, if it's present ๐Ÿ’–


โœจ OPTIONS โœจ

  • -dinterval โ€” daemonize and repeat cache cleaning every interval minutes. this one is mutually exclusive with -D, -v and -r. to shut the daemon down cleanly, just send it a SIGTERM or SIGINT ๐Ÿ‘‘
  • -D โ€” do a dry run, don't delete anything. mutually exclusive with -d. and heads up bestie, when you're doing a dry run and deleting directories with -t, the inodes reported deleted in the stats can't take the deleted directories into account, so they'll be marked as an estimate ๐Ÿ“
  • -v โ€” be verbose and print statistics. mutually exclusive with -d โœจ
  • -r โ€” clean thoroughly. this assumes the Apache web server is not running (otherwise you may get garbage in the cache ๐Ÿ˜ญ). mutually exclusive with -d, and it implies -t
  • -n โ€” be nice ๐Ÿฅบ this causes slower processing in favor of other processes. htcacheclean will sleep from time to time so that (a) the disk IO gets delayed and (b) the kernel can schedule other processes in the meantime
  • -t โ€” delete all empty directories. by default only cache files are removed, but with some configurations the huge number of directories created may need attention. if your config needs a very large number of directories โ€” to the point that inode or file allocation table exhaustion could become an issue โ€” use of this option is advised โš ๏ธ
  • -ppath โ€” specify path as the root directory of the disk cache. this should be the same value you specified with the CacheRoot directive ๐Ÿ“
  • -Ppidfile โ€” specify pidfile as the name of the file to write the process ID to when daemonized ๐Ÿ“Œ
  • -Rround โ€” specify round as the amount to round sizes up to, to compensate for disk block sizes. set it to the block size of the cache partition ๐Ÿ”ข
  • -llimit โ€” specify limit as the total disk cache size limit. the value is expressed in bytes by default (or by attaching B to the number). attach K for Kbytes, M for MBytes or G for Gbytes ๐Ÿ’พ
  • -Llimit โ€” specify limit as the total disk cache inode limit. K, M or G suffix can also be used here ๐Ÿงฎ
  • -i โ€” be intelligent and run only when there was a modification of the disk cache. this option is only possible together with -d ๐Ÿง 
  • -a โ€” list the URLs currently stored in the cache. variants of the same URL will be listed once for each variant ๐Ÿ“‹
  • -A โ€” list the URLs currently stored in the cache, along with their attributes in the following order: url, header size, body size, status, entity version, date, expiry, request time, response time, body present, head request ๐Ÿ”

๐Ÿ’… DELETING A SPECIFIC URL ๐Ÿ’…

if htcacheclean is passed one or more URLs, each URL will be deleted from the cache. and if multiple variants of an URL exist, all variants get deleted. bye bestie ๐Ÿ‘‹

when a reverse proxied URL is the one being deleted, the effective URL is constructed from the Host header, the port, the path and the query. and listen โ€” the ? in the URL must always be specified explicitly, whether a query string is present or not ๐Ÿซ 

for example: an attempt to delete the path / from the server localhost, the URL to delete would be:

http://localhost:80/?

๐ŸŒˆ LISTING URLS IN THE CACHE ๐ŸŒˆ

by passing the -a or -A options to htcacheclean, the URLs within the cache will be listed as they are found, one URL per line โœจ

the -A option dumps the full cache entry after the URL, with fields in the following order:

  • url โ€” the URL of the entry ๐Ÿ”—
  • header size โ€” the size of the header in bytes
  • body size โ€” the size of the body in bytes
  • status โ€” status of the cached response
  • entity version โ€” the number of times this entry has been revalidated without being deleted ๐Ÿ”
  • date โ€” date of the response
  • expiry โ€” expiry date of the response โณ
  • request time โ€” time of the start of the request
  • response time โ€” time of the end of the request
  • body present โ€” if 0, no body is stored with this request, 1 otherwise
  • head request โ€” if 1, the entry contains a cached HEAD request with no body, 0 otherwise

๐Ÿ’€ EXIT STATUS ๐Ÿ’€

htcacheclean returns a zero status ("true") if all operations were successful, 1 otherwise.

if an URL is specified, and the URL was cached and successfully removed, 0 is returned, 2 otherwise. and if an error occurred during URL removal, 1 is returned ๐Ÿ˜ต


๐Ÿ“ FILES ๐Ÿ“

the cache root directory is specified as an argument on the command line and should match the CacheRoot directive in the server configuration.

  • path โ€” the root directory of the disk cache to be cleaned ๐Ÿงผ

that's the whole page bestie, you ate it. now go clean that cache ๐Ÿ’–โœจ

Apache HTTP Server โ€” 2026-05-08 โ€” HTCACHECLEAN(8) ๐ŸŽ€๐Ÿฆ‹๐Ÿ’…

๐Ÿ“ฆ where this page comes from