Skip to content

Instantly share code, notes, and snippets.

@barrymw
Created October 6, 2022 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barrymw/358f833df67c6d5fb45391a3444baaa1 to your computer and use it in GitHub Desktop.
Save barrymw/358f833df67c6d5fb45391a3444baaa1 to your computer and use it in GitHub Desktop.
Enable purging of files in squid cache

TL;DR

Ensure that your squid.conf includes the following configuration.

acl localhost  src 127.0.0.1/32 ::1
acl manager proto cache_object
acl purge method PURGE

# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access allow localhost purge
http_access deny manager
http_access deny purge

squidclient -m PURGE <URL that is cached when it shouldn't be>

E.g:

# squidclient -m PURGE http://mirror.aarnet.edu.au/pub/centos/7.9.2009/updates/x86_64/repodata/repomd.xml
HTTP/1.0 200 OK
Server: squid/m.n.pp
Mime-Version: 1.0
Date: Thu, 06 Oct 2022 02:05:16 GMT
Content-Length: 0
X-Cache: MISS from proxy.somewhere
X-Cache-Lookup: NONE from proxy.somewhere:3128
Via: 1.0 proxy.somewhere (squid/m.n.pp)
Connection: close

If the URL isn't in the cache, the return code will be 404 Not Found instead of 200 OK.

This was based on the info found on https://help.getbusi.com/article/43-removing-individual-objects-from-squid-cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment