44.4. Adding Cache Directories

In its usual default configuration, Squid uses a single directory for storing cached pages. At most, 100 MB of data will be stored in this directory, which is not likely to be enough if serving a large number of active clients. If your system has more than one hard drive, it makes sense to spread the cache across multiple disks to improve performance. This can be done by specifying multiple directories, each with its own maximum size.

On a system that is dedicated to running a proxy server, the maximum amount to cache in each directory should be about 90 percent of the available space. It is unwise to configure or allow Squid to use up all free disk space, as many filesystems suffer reduced performance when nearly full. Furthermore, disk space may be used by log files and user data as well. If Squid fills up your entire hard drive, problems may occur because other programs are unable to create temporary files or write to logs.

To add a new cache directory and specify the maximum size for the existing one, follow these steps:

1.
Click on the Cache Options icon on the module's main page to bring up the form shown in Figure 44.3.

Figure 44.3. The cache options form.


2.
In the Cache directories field, select the Listed option. If Default was chosen before, Squid will have been using the single compiled-in default cache directory displayed in brackets. If you want to continue using this directory, it must be explicitly entered into the table. The default size is 100 MB, and it uses 16 1st level and 256 2nd level directories.

Each row in the table specifies a single cache directory. Any existing directories (apart from the default) will be listed so that you can edit them, followed by a single blank row. Each row has fields under the following columns:

Directory The full path to the top-level cache directory, such as /var/spool/squid or /disk2/cache. This directory must already exist and be owned by the user as whom Squid runs (usually called squid). The module will not create it for you.

Type The storage type used in the directory. You should always select UFS here.

Size (MB) The maximum amount of data that it will contain, in megabytes. Once this limit is reached, the oldest unrequested files will be replaced with new ones.

1st level dirs The number of subdirectories that will be created under the cache directory. The default of 16 is usually fine, but you may want to increase this for very large caches.

2nd level dirs The number of subdirectories that will be created under each first-level directory. You should just enter 256, unless your cache is going to be very large.

Options Leave this field blank—it is only used for other directory types.

If you are wondering why Squid needs to create two levels of subdirectories under each cache directory, the reason is the poor performance of many filesystems when a directory contains a large number of files. Because every single cached HTML page or image is stored in a separate file, the number of files on a busy proxy system can be huge. Spreading them across multiple directories solves this problem.

3.
After adding a directory, hit the Save button at the bottom of the page. If you want to add more than one, you will need to click on the Cache Options icon again to redisplay the table with a new empty row.

4.
When you are done defining directories, return to the module's main page. If a new one has been added, an error message like Your Squid cache directories have not been initialized will be displayed. Hit the Initialize Cache button to have Squid create all the subdirectories in any new cache directories. The server will be shut down during the process and re-started when it is complete.

5.
After initialization is complete, click on the Apply Changes link on any page to start using your new directories.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.95.216