purge is used to have a look at what URLs are stored in which file within your cache. The purge tool can also be used to release objects which URLs match user specified regular expressions. A more troublesome feature is the ability to remove files squid does not seem to know about any longer.
This is a tool for expert usage only, use it under your own responsibility.
If you use a value other than 0 or 1, you will need to slow
rebuild your cache content. A warning message will remind you
of that. If you use bit#1, all unsuccessful PURGEs will result
in the object file in your cache directory to be removed, because
squid does not seem to know about it any longer. Beware that the
asyncio might try to remove it after the purge tool, and thus
complains bitterly. Bit#1 only makes sense, if Bit#0 is also
set, otherwise it has no effect (since the HTTP status 404 is
never returned).
Bit#2 is reserved for strange files which do not even contain a URL. Beware that these files may indicate a new object squid currently intends to swap onto disk. If the file suddenly went away, or is removed when squid tries to fetch the object, it will complain bitterly. You must slow rebuild your cache, if you use this option.
It is recommended that if you dare to use bit#1 or bit#2, you
should only grant the purge tool access to your squid, e.g.
move the HTTP and ICP listening port of squid to a different
non-standard location during the purge.
default: 0 (just print)
In order to use purge to affect a running proxy with PURGE method, you will have to enable this feature in squid.conf. By default, PURGE is disabled. You should watch closely for whom you enable the PURGE ability, otherwise a total stranger just might wipe your cache content. Lines similar to the following will need to be added to your squid.conf:
acl purge method PURGE
http_access allow localhost purge
http_access deny purge
Reconfigure or restart (preferred) your squid after changing the configuration file.
In regular mode, the output of purge consists of four columns. If the
URL contains not encoded whitespaces, it may look as if there are more
columns, but the last one is the URI.
# name meaning
= ====== ===========================================================
1 file name of cache file eximed which matches the regular expression.
2 status return result of purge request, " 0" in print mode.
3 size object size including stored headers, not file size.
4 uri perceived uri
Example for non-verbose output in print-mode:
/cache3/00/00/0000004A 0 5682 http://graphics.userfriendly.org/images/slovenia.gif
In verbose mode, additional columns are inserted before the uri. Time
stamps are reported using hexadecimal notation, and Squid's standard
for reporting "no such timestamp" == -1, and "unparsable timestamp" == -2.
# name meaning
= ====== ===========================================================
1 file name of cache file eximed which matches the re.
2 status return result of purge request, " 0" in print mode "-P 0".
3 size object size including stored headers, not file size.
4 md5 MD5 of URI from file, or "(no_md5_data_available)" string.
5 ts UTC of Value of Date: header in hex notation
6 lr UTC of last time the object was referenced
7 ex UTC of Expires: header
8 lr UTC of Last-Modified: header
9 flags Value of objects flags field in hex, see: Programmers Guide
10 refcnt number of times the object was referenced.
11 uri STORE_META_URL uri or "strange_file"
Example for verbose output in print-mode:
/cache1/00/00/000000B7 0 406 7CFCB1D319F158ADC9CFD991BB8F6DCE 397d449b 39bf677b ffffffff 3820abfc 0460 1 http://www.netscape.com/images/nc_vera_tile.gif
It is still relatively slow, especially if your machine is low on memory and/or unable to hold all OS directory cache entries in main memory.
Should never be used on "busy" caches with purge modes higher than 1.
1) use the stat() result on weird files to have a look at their ctime and mtime. If they are younger than, lets say 30 seconds, they were just created by squid and should not be removed.
2) Add a query before purging objects or removing files, and add another option to remove nagging for the experienced user.
3) The reported object size may be off by one.
Based on original squidpurge README.
* Copyright (C) 1996-2021 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.
Report bugs or bug fixes using http://bugs.squid-cache.org/
Report serious security bugs to Squid Bugs <squid-bugs@lists.squid-cache.org>
Report ideas for new improvements to the Squid Developers mailing list <squid-dev@lists.squid-cache.org>