How To Increase Squid’s Cache Directory Swap Size
At times, granted a high-end server capacity and resources with large disk and memory capacity,
increase squid’s disk cache size is highly advisable. With higher disk cache size, you provide a higher
amount of disk space to be used by squid on caching web files.
Increase Squid Cache Directory Swap Size
With default Squid rpm installation, the default value of squid cache directory swap size is set to 100MB.
Having a large disk storage would be efficient to store a larger directory swap size for squid to use.
Simply edit /etc/squid/squid.conf and find the cache directory squid directive
cache_dir ufs /var/spool/squid 100 16 256
/var/spool/squid is the directory folder location where squid will use to swap cached web files.
100 the first number is the amount of disk space in MB to be used by squid for caching directory.
16 is the number of first-level sub directories which will be created under the ‘Directory’.
256 is the number of second-level sub directories which will be created under each first-level directory.
To verify your disk and partition sizes, simply
# df -ah
giving you a similar lines
/dev/sda3 49G 4.5G 42G 10% /var
/dev/sda2 387G 18G 350G 5% /home
/dev/sda1 99M 12M 83M 13% /boot
From default squid installation, cache dir is physically dumped to /var directory by default.
Now, considering a server with high space, say 40GB free disk partition size, you could reconfigure
squid cache_dir to a value of
cache_dir ufs /var/spool/squid 2000 32 512
That is 2GB of cache directory for squid to use with 512 second-level directory under the first level of 32.
Save, exit and create the cache directory.
Stop Squid first
# service squid stop
Recreate Squid Cache Directory
# squid -z
Start Squid Service
# service squid start
This setup would nicely suit a large and regular internet user infrastructure setup.
All done.