Do-It-Yourself Caching: Squid 2.3 - page 7
Why Caching is Essential
Once you've stabilized Squid, you can then proceed to fine-tune its operating efficiency. The configuration file contains over 100 tuning knobs. Among other things, you can:
- modify listening ports, IP addresses, hostnames and connect, select, request and ident timeouts
- modify outgoing ports to spread response handling across multiple interfaces
- specify ICP ports, neighbor selection criteria (including weight and TTL) and cache digests
- set cache swap high and low water marks for cache object replacement
- limit the largest object size or prevent caching based on URL substrings
- determine the location, size and index levels for cache storage configure the size and refresh behavior for the IP and FQDN (DNS) caches
- enable and configure memory pools to increase speed
- enable and configure delay pools to constrain bandwidth
- set maximum HTTP request and reply body and header sizes to protect against DOS attacks
- define min / max lifetimes for objects without TTL, identified by URL regular expression
- choose a replacement policy (see below)
Earlier versions of Squid had a single self-explanatory replacement policy: Least Recently Used (LRU). In version 2.3, you can also choose Greedy-Dual Size Frequency (GDSF) or Least Frequently Used with Dynamic Aging (LFUDA). GDSF gives priority to smaller objects that have a better chance of getting hit. LFUDA is more like LRU, but employs a dynamic aging mechanism that is said to be more efficient than recent usage. Generally, GDSF produces a higher hit rate, while LFUDA reduces WAN bandwidth use. For further details, follow the URLs supplied in squid.conf.
Squid can't provide the patented adaptive or predictive refresh methods used by some commercial caching products and doesn't include the ability to preload specified high-utilization sites. However, it is quite simple to write a script that uses wget to download sites, invoked on a scheduled basis by cron.
You'll find a tuning tips to increase hit rate, improve response time and optimize cache performance in the Squid FAQ. The Cache Manager offers instantaneous, tabular stats. General Runtime Info summarizes HTTP, ICP and DNS request rates, hit ratios, median service times, mean object size, CPU, memory, swap and file descriptor usage.