A Squid server is a proxy distributed as free software. The principle of the proxy is to keep some items cached to increase the browsing speed of users. However, sometimes it can be awkward to keep some items cached, for example for a web developer wanting to view changes he has just made on a website. In the rest of this page, you will learn how to purge the elements for a selected site.
MODIFY SQUID CONFIGURATION TO ALLOW PURGE
As a first step, you need to modify the Squid configuration file (squid.conf) to allow the purge. To do this, edit the file /etc/squid/squid.conf
and add the following lines:
acl PURGE method purge http_access allow purge localhost http_access deny purge
You must now add a password for the cache manager (cache_mgr), always in the add a line configuration file:
cachemgr_passwd password objects
The objects option allows to limit the field of action to the manager, however it will be possible to purge the cache.
Finally, for your new configuration to be taken into account, in the console of your proxy enter the line:
squid -k reconfigure
MAKE A LIST OF OBJECTS THAT YOU WANT TO DELETE
To create a list “lst-obj”, which contains all the objects coming from the site linuxfr for example, you just have to enter the following line in the console of your proxy:
squidclient -p 8080 -U manager -W password mgr: objects | grep linuxen > lst-obj
You can view the lst-obj list with the following line:
more lst-obj GET http://linuxfr.org/2009/04/images/ecrire.png GET http://linuxfr.org/forums/images/ecrire.png GET http://linuxfr.org/backend/journals/rss20.rss GET http://linuxfr.org/~Zenitram/28107.html GET http://linuxfr.org/forums/10/9666.html GET http://linuxfr.org/forums/ 30/23427 .html GET http://linuxfr.org/2007/03/images/ecrire.png GET http://linuxfr.org/css/contrib/nightgrey.css GET http://linuxfr.org/css/linux_print.css GET http://linuxfr.org/2009/04/09/25285.html
PURGE OBJECTS IN THE LIST
You can now delete the objects you put in the lst-obj list, by running the following line:
cut -d "" -f2 lst-obj | xargs -n 1 squidclient -m PURGE -p 8080
The proxy then confirms the purge by displaying the list of deleted items.
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Recent Posts: TechnoBlogy