How to clear Squid Proxy Cache on Debian and Ubuntu

.

In this tutorial i will show how to clear squid proxy cache on Debian and Ubuntu Linux. It was necessery to clean up some squid cache for some proxy users on a Debian host. Until now I’ve used to run only custom build Squid server on Slackware Linux.

Thus I was curious if Debian guys were smart enough to implement a proxy cache cleaning option as an option to be passed on to squid’s init script.

Honestly I was quite suprised squid clear cache option is not there;

squid-cache:~# /etc/init.d/squid3
Usage: /etc/init.d/squid3 {start|stop|reload|force-reload|restart}
squid-cache:/#

As it was not embedded into init script I still hoped, there might be some Debian way to do the proxy cache clearing, so I spend some 10 minutes checking online as well as checked in squid3‘s manual just to find there is no specific command or Debian accepted way to clean squid’s cache.

Since I couldn’t find any Debian specific, way I did it the old fashioned way icon wink How to clear Squid Proxy Cache on Debian and Ubuntu (deleted directory/file structures in /var/spool/squid3/* and used squid’s -z option, to recreate the swap directories.

Here is how:

squid-cache:~# /etc/init.d/squid3 stop;
squid-cache:~# rm -Rf /var/spool/squid3/*;
squid-cache:~# squid3 -z; /etc/init.d/squid3 start

Finally I was quite amazed to realize, there was not even a crontab script to periodically clear and re-create proxy cache.

My previous experience with maintaning an office Squid proxy cache has prooved, that periodic cache clean ups are very helpful, especially to resolve issues with cached unreslovable DNS entries in the server.
Clearing up squid cache every week or something, guarantees that failure to resolve certain hosts at certain times would not stay unresolvable like forever icon wink How to clear Squid Proxy Cache on Debian and Ubuntu

In that manner of thougths, I decided to put the following crontab which will twice a month clear up proxy’s cache, to possibly solve some failed squid DNS issues.

squid-cache:~# crontab -u root -l > file;
echo '00 04 12,26 * * /etc/init.d/squid3 stop; rm -Rf /var/spool/squid3/*; squid3 -z; /etc/init.d/squid3 start >/dev/null 2>&1'
>> file; crontab file

By the way, implementing the squid clear cache in Debian and Ubuntu ‘s init scripts and putting a periodic proxy clear up cron, seems like a feature worthy to be proposed to the distro developers and hopefully be embbed in some of the upcoming distro releases icon wink How to clear Squid Proxy Cache on Debian and Ubuntu

 How to clear Squid Proxy Cache on Debian and Ubuntu

About Frank Boros

Frank Boros has written 107 post in this blog.

Incoming search terms:

Be Sociable, Share!
  • more How to clear Squid Proxy Cache on Debian and Ubuntu

    You can leave a response, or trackback from your own site.

    One Response to “How to clear Squid Proxy Cache on Debian and Ubuntu”

    1. boleh.net says:

      Thank you for your great tutorial. i need this bacause my disk full. And i need to cleaning cache proxy :)

    Leave a Reply


    3 − one =

    Powered by WordPress | Designed by: best suv | Thanks to trucks, infiniti suv and toyota suv
    show
     
    close
    Email
    Print
    WP Socializer Aakash Web
    promotepoint's Profile on Ping.sg