To cache files properly, you can use certain tags that define where and how cache files are created. To understand how this works, you should know that Squid can cache files in memory, as well as on hard disk. Memory is faster, so if speed is an issue, allocate as much memory as possible for caching files. However, always configure your file system to cache files as quickly as possible, which will lead to the maximum possible performance. Table 25-1 lists the tags that are used for this purpose.
Table 25-1. Tags to Define Where and How Cache Is Created Tags Meaning cache_mem This tag specifies the amount of memory Squid should use for file cache. The default value of 8MB is conservative. On a dedicated Squid server with 1GB of available memory, you won't have any problems by setting it to 512MB.
cache_swap_low and cache_swap_high If you might run out of drive space, perhaps because of too many cache files, you can use these tags to start cleaning up files automatically. For this process, you use a least recently used algorithm; if an item is sitting in cache and hasn't been used for a long time, it will be removed first. The cache_swap_low tag, which is set to 90 percent by default, defines when the file cleanup should start, and the cache_swap_high tag defines when file cleanup should start to happen more aggressively.
This specifies the maximum size of an object to be cached. By default, this tag is set to the rather low value of 4,096KB. Therefore, an ISO file that is downloaded frequently from your network will never be cached. If you have considerable cache space, consider setting this tag much higher.
This sets the minimum size of an object that can be cached. By default, this tag is set to 0 bytes. This is a good setting because it also allows small files to be stored in cache.
maximum_oDject_size_in_memory This sets the maximum size of a file that is to be cached in the memory of your server. By default, the maximum size for the object in memory is set to 8KB; consider setting it much higher.
Was this article helpful?