By default, the PURGE method is denied with squid, therefore, you cannot use squidclient to purge the cache for a particular page.
The solution to this requires a change in your squid.conf file to allow the PURGE method from localhost.
At my site, squid is installed at /usr/local/squid and the server listens on ports 80 and 8080 instead of the default 3128. You can see what ports squid is listening on with the following:
|
1 2 3 |
# grep "^http_port" /usr/local/squid/etc/squid.conf http_port proxy_ip_addr:80 http_port proxy_ip_addr:8080 |
First, we need to add a couple of acl‘s to the configuration file, one for localhost (if you haven’t defined it already), and one for the PURGE method itself.
|
1 2 3 4 |
# vi /usr/local/squid/etc/squid.conf # egrep "^(acl PUR|acl local)" /usr/local/squid/etc/squid.conf acl localhost src 127.0.0.1 acl PURGE method PURGE |
Now, we can add our http_access definitions to allow use of the PURGE method when requested by localhost only. Make sure you add both of these entries before your global http_access deny all entry.
|
1 2 3 4 |
# vi /usr/local/squid/etc/squid.conf # grep "^http_access.*PURGE" /usr/local/squid/etc/squid.conf http_access allow PURGE localhost http_access deny PURGE |
Now, we’re ready to ask squid to reload its configuration file.
|
1 |
# /etc/init.d/squid reload |
No errors? Cool. Now we can attempt to PURGE our cache for a particular page …
|
1 |
# /usr/local/squid/bin/squidclient -h proxy_ip_addr -p 80 -m PURGE http://www.somewhere.com/somepage.html |
If the object is in the cache, you should receive a HTTP/1.0 200 OK message. If the object is not in the cache, you’ll be greeted by a HTTP/1.0 404 Not Found message.