Delete Remove Clear Squid Cache on Linux Fedora System

 

Step by Step Delete Remove Clear Squid Cache on Linux Fedora System.

 

   The step by step below show the step to delete remove or clear squid cache on Linux Fedora system.  The example below show the faster way to clear squid cache and start squid again using clean cache file.  This step by step to clear squid cache is tested and done on Linux Fedora 10 system and may be use on other Linux Fedora system with squid installed :-).

 

Check Squid Cache Location.

 

1.  Check squid cache location on your Linux system.  the default location may be at /var/spool/squid directory, but you can use command as show on the example below to check squid cache directory on your system.

Check squid cache location on your Linux system.

[root@fedora10 ~]# cat /etc/squid/squid.conf | grep ^cache_dir

cache_dir ufs /var/spool/squid 4000 16 256

[root@fedora10 ~]#

 

2.  Verify squid cache directory by list contents inside squid cache directory.  The contents of squid cache directory should look like on example below.

Contents of squid cache directory.

[root@fedora10 ~]# ls /var/spool/squid

00  02  04  06  08  0A  0C  0E  swap.state

01  03  05  07  09  0B  0D  0F

[root@fedora10 ~]#

 

Stop squid cache proxy server.

 

  In order to clear squid cache, we need to stop squid proxy first.  the step below show example to stop squid proxy server on Linux Fedora system.  NOTE:- Make sure that you stop squid proxy first before attempt to clear squid cache.

 

3.  Check squid proxy status.

Check squid proxy status.

[root@fedora ~]# service squid status

squid (pid  7593) is running...

[root@fedora ~]#

 

4.  Stop squid proxy server.

Stop squid proxy server.

[root@fedora ~]# service squid stop

Stopping squid: ................                           [  OK  ]

[root@fedora ~]#

 

5.  Verify that squid proxy is stop.

Stop squid and verify that squid proxy is stop.

[root@fedora ~]# service squid status

squid is stopped

[root@fedora ~]#

 

Create directory and move squid cache file.

 

  Create new directory to temporary store the old squid cache files... why we shoud do this??? the answer... to minimize squid proxy downtime.  First we need to create directory and then move the old squid cache file to this directory.

 

6.  Make directory and verify.

Make directory and verify.

[root@fedora ~]# mkdir /var/spool/squid/squid_cache_old

[root@fedora ~]#

[root@fedora ~]# ls /var/spool/squid/

00  02  04  06  08  0A  0C  0E  squid_cache_old  swap.state.last-clean

01  03  05  07  09  0B  0D  0F  swap.state

[root@fedora ~]#

 

7.  Then move and clear squid cache directory contents to /var/spool/squid/squid_cache_old directory.

Move and clear squid cache directory contents.

[root@fedora ~]# mv /var/spool/squid/?? /var/spool/squid/squid_cache_old/

[root@fedora ~]# mv /var/spool/squid/swap* /var/spool/squid/squid_cache_old/

[root@fedora ~]#

 

8.  Verify the contents of the squid cache directory.

Empty squid cache and verify the contents of the squid cache directory.

[root@fedora ~]# ls /var/spool/squid/

squid_cache_old

[root@fedora ~]#

 

Start squid with new cache.

 

9.  Create squid cache directory (Rebuild squid cache).

Create squid cache directory (Rebuild squid cache).

[root@fedora ~]# squid -z

2009/06/08 07:16:32| Creating Swap Directories

2009/06/08 07:16:32| /var/spool/squid exists

2009/06/08 07:16:32| Making directories in /var/spool/squid/00

2009/06/08 07:16:32| Making directories in /var/spool/squid/01

2009/06/08 07:16:32| Making directories in /var/spool/squid/02

2009/06/08 07:16:32| Making directories in /var/spool/squid/03

2009/06/08 07:16:32| Making directories in /var/spool/squid/04

2009/06/08 07:16:32| Making directories in /var/spool/squid/05

2009/06/08 07:16:32| Making directories in /var/spool/squid/06

2009/06/08 07:16:32| Making directories in /var/spool/squid/07

2009/06/08 07:16:32| Making directories in /var/spool/squid/08

2009/06/08 07:16:32| Making directories in /var/spool/squid/09

2009/06/08 07:16:32| Making directories in /var/spool/squid/0A

2009/06/08 07:16:32| Making directories in /var/spool/squid/0B

2009/06/08 07:16:32| Making directories in /var/spool/squid/0C

2009/06/08 07:16:32| Making directories in /var/spool/squid/0D

2009/06/08 07:16:32| Making directories in /var/spool/squid/0E

2009/06/08 07:16:32| Making directories in /var/spool/squid/0F

[root@fedora ~]#

 

10.  View squid cache directory contents to verify the cache file exist.

View squid cache directory contents to verify the cache file exist.

[root@fedora ~]# ls /var/spool/squid/

00  02  04  06  08  0A  0C  0E  squid_cache_old

01  03  05  07  09  0B  0D  0F

[root@fedora ~]#

 

11.  Start squid with new clean cache, and then verify squid proxy server is up and running.

Start squid with new clean cache, verify squid proxy server up and running.

[root@fedora ~]# service squid start

Starting squid: .                                          [  OK  ]

[root@fedora ~]#

[root@fedora ~]# service squid status

squid (pid  9202) is running...

[root@fedora ~]#

 

Remove squid cache.

 

  Then remove old squid cache, this part should be done after you start the squid proxy server with new clean cache file.  This part may take a while base on the size of squid cache directory.  Please Note:- If you follow this article correctly, total downtime of your squid proxy server may be under 1 minutes because we already start squid proxy server with clean cache and after that we remove old squid cache file that may take lot of overall time to complete the procedure.

 

12.  Remove squid cache in the /var/spool/squid//squid_cache_old directory. Do this step with caution...

Remove squid cache in the /var/spool/squid//squid_cache_old directory.

[root@fedora ~]# rm -rf /var/spool/squid/squid_cache_old/

[root@fedora ~]#

 

Keywords: clear squid cache, remove squid cache, delete squid cache, clean squid cache, rebuild squid cache, squid cache directory  

 

2 comments

19
Apr

Nice info! :D Thx mate

Nice info! :D Thx mate

10
Oct

WOW...its really Awesome.

WOW...its really Awesome. Actually Iam newly joined Linux Administrator in Medium Scale Company....& my team lead give me the access, IP Address, password of the Proxy server & tell me to Clear the Squid Cache....So that time I got cramped as I never did this type of job ever before But Thanks to you Sir...with the Help of this Article I did the Needful So at the end of the Day "BOSS is Happy & ME too"..& this is only because of You...So Thank you very much. This is the reason why IT Engineers believe in Goggling & referring standard Article...is this.