Increasing squid cache directory size

→ Are you a new visitor? Please visit the page guidance for new visitors ←

Increasing squid cache directory size

The past weeks I had to set a reverse proxy using squid. For those who don’t know, squid is a web proxy, but can be used as a reverse proxy and web accelerator.

So in my cases I used squid as both a reverse proxy and web accelerator. In this article however I’m going to explain an easy way to increase or create a cache directory for squid.

This is rather useful for caching web files on disk rather then always query the web server. The default installation of squid from yum or apt should have the cache directory size up to 100MB.

To increase the cache directory size, simply edit the file /etc/squid/squid.conf and locate the directive:

By default, the cache_dir directory may be commented.

  • /var/spool/squid – This is the directory folder where squid will use to swap cache your server web files
  • 100 – The amount of disk space to use in MB for your caching directory
  • 16 – the first-level subdirectories which will be created in your cache directory
  • 256 – The number of second-level subdirectories which will be created under each first level directory

Next you need to consider how much disk space you wish to allow for caching, for example, lets say we wish to allocate 3GB of space to squid cache. We would use the following directive:

This will allocate 3GB of disk space to your squid cache directory. Save the file and exit.

Then make sure squid is fully stopped:

Run the following command to recreate the Squid Cache Directory:

Then start the service again:

That’s all! Enjoy your new Squid configuration!

Request an article ←