AboutBlogContact
DevOps & InfrastructureAugust 15, 1999 2 min read 130Updated: June 22, 2026

Squeezing Every Byte: Squid Cache Optimization (1999)

AunimedaAunimeda
📋 Table of Contents

Squeezing Every Byte: Squid Cache Optimization

As we approach the turn of the millennium, web traffic is skyrocketing. If you're serving images and scripts directly from your Apache 1.3 servers, you're wasting precious CPU cycles and RAM on process forking. You need a dedicated reverse proxy. Squid 2.2 is the industry standard for a reason, but the default squid.conf is far from optimal for a high-load environment.

Memory Management: The cache_mem Trap

Many admins think setting cache_mem to a huge value will make Squid faster. Wrong. cache_mem only sets the limit for in-transit objects and "hot" objects. If you set it too high, the OS will swap, and your latency will go through the roof. For a 256MB RAM server, keep it around 64MB. Let the filesystem cache handle the rest.

Disk I/O: Use aufs

The standard ufs storage module is blocking. Every time Squid writes a cache hit to disk, the whole process waits. On Linux, switch to aufs (Async UFS). It uses threads to handle disk I/O, allowing the main loop to keep serving requests.

# squid.conf
cache_dir aufs /var/spool/squid 2000 16 256

Fine-Tuning Refresh Patterns

Don't trust the origin server's headers blindly. Many older CGIs don't send proper Expires tags. Use refresh_pattern to force caching of static types.

refresh_pattern \.gif$ 1440 20% 10080
refresh_pattern \.jpg$ 1440 20% 10080
refresh_pattern \.js$  1440 20% 10080

The File Descriptor Limit

By default, many Unix systems limit processes to 256 or 1024 file descriptors. On a busy site, Squid will hit this in minutes. You must increase this at the OS level and recompile Squid with --enable-poll.

ulimit -n 4096
# Then start squid

If you aren't monitoring your hit ratio, you're flying blind. A well-tuned Squid should be hitting 40-60% of requests, taking a massive load off your backend database and application servers.


Aunimeda provides DevOps engineering and infrastructure services - CI/CD pipelines, containerization, cloud deployments, and monitoring setups.

Contact us to discuss your infrastructure needs. See also: DevOps Services, Custom Software Development

Read Also

Turborepo: High-Performance Monorepos with Remote Caching (2022)aunimeda
DevOps & Infrastructure

Turborepo: High-Performance Monorepos with Remote Caching (2022)

The Vercel acquisition of Turborepo has put monorepos in the spotlight. Let's explore how task graphs and remote caching make builds sub-second.

Kafka: Zero-Copy and Why It's Fast (2015)aunimeda
DevOps & Infrastructure

Kafka: Zero-Copy and Why It's Fast (2015)

How does Kafka push gigabits of data on commodity hardware? The secret isn't in the code; it's in the Linux kernel's sendfile() call.

The 2008 Scaling Crisis: Caching at the Edge with Memcachedaunimeda
DevOps & Infrastructure

The 2008 Scaling Crisis: Caching at the Edge with Memcached

Your database is the bottleneck. In 2008, if you're hitting your MySQL server for every user profile, you're not scaling. It's time to offload the heavy lifting to a distributed memory pool.

Need IT development for your business?

We build websites, mobile apps and AI solutions. Free consultation.

DevOps Services

Get Consultation All articles