Configure Cherokee caching and compression for improved performance

Intermediate 25 min Jun 06, 2026 55 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Set up Cherokee web server with advanced caching modules and gzip compression to dramatically improve page load times and reduce bandwidth usage for high-traffic websites.

Prerequisites

  • Root or sudo access
  • Basic understanding of web servers
  • At least 2GB RAM for optimal caching

What this solves

Cherokee web server offers built-in caching and compression features that can significantly reduce response times and bandwidth usage. This tutorial configures Cherokee's caching modules to store frequently requested content and enables gzip compression to reduce file sizes, improving performance for websites with heavy traffic or slow connections.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure you have access to the latest Cherokee packages and dependencies.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install Cherokee web server

Install Cherokee along with the administration interface for easy configuration management.

sudo apt install -y cherokee cherokee-admin libcherokee-mod-libssl libcherokee-mod-streaming
sudo dnf install -y cherokee cherokee-admin

Enable and start Cherokee service

Enable Cherokee to start automatically on boot and start the service immediately.

sudo systemctl enable cherokee
sudo systemctl start cherokee
sudo systemctl status cherokee

Launch Cherokee admin interface

Start the Cherokee admin interface to access the web-based configuration panel. This creates a temporary admin user and password.

sudo cherokee-admin -b

The command will output the admin URL and credentials. Keep this terminal open and access the admin interface at http://your-server-ip:9090.

Configure caching modules

Enable file caching

In the Cherokee admin interface, navigate to Virtual Servers → Default → Advanced → File Cache to enable static file caching.

Configure the following settings in the admin panel:

  • Enable File Cache: Yes
  • Cache Directory: /var/lib/cherokee/cache
  • Max File Size: 10MB
  • Cache Expiry: 3600 seconds

Create cache directory

Create the cache directory and set proper permissions for the Cherokee web server user.

sudo mkdir -p /var/lib/cherokee/cache
sudo chown www-data:www-data /var/lib/cherokee/cache
sudo chmod 755 /var/lib/cherokee/cache

Configure static content caching rules

In the admin interface, go to Virtual Servers → Default → Behavior and create a new rule for static content caching.

Add a new rule with these settings:

  • Rule Type: Extensions
  • Extensions: css,js,png,jpg,jpeg,gif,ico,pdf,zip
  • Handler: Static files
  • Expiration: 1 month

Enable memory caching

Navigate to Virtual Servers → Default → Advanced → Memory Cache to configure in-memory caching for frequently accessed files.

Configure these memory cache settings:

  • Enable Memory Cache: Yes
  • Max Memory Usage: 128MB
  • Max File Size: 1MB
  • File Extensions: css,js,html,htm

Configure compression

Enable gzip compression

In the Cherokee admin interface, navigate to Virtual Servers → Default → Advanced → Compression to enable gzip compression.

Configure compression settings:

  • Enable Compression: Yes
  • Compression Level: 6 (balance between CPU usage and compression ratio)
  • Minimum File Size: 1024 bytes
  • Maximum File Size: 1MB

Configure compression for specific file types

Create a new behavior rule for compressible content types. Go to Virtual Servers → Default → Behavior and add a new rule.

Configure the compression rule:

  • Rule Type: Extensions
  • Extensions: html,htm,css,js,xml,txt,json,svg
  • Handler: Static files
  • Transforms: Gzip encoding

Set compression headers

Navigate to Virtual Servers → Default → Advanced → Header Ops to add compression-related headers that help browsers and proxies handle cached content correctly.

Add these header operations:

  • Operation: Add
  • Header: Vary
  • Value: Accept-Encoding

Performance optimization

Configure Cherokee performance settings

Navigate to General → Performance in the admin interface to optimize Cherokee's worker processes and connection handling.

Adjust these performance settings:

  • Thread Number: Set to number of CPU cores × 2
  • Connection Reuse: Enabled
  • Sendfile: Enabled
  • TCP NoDelay: Enabled

Configure timeout settings

In General → Network, optimize timeout values for better performance under load.

Set these timeout values:

  • Timeout: 15 seconds
  • Keep Alive: Enabled
  • Keep Alive Requests: 500
  • Keep Alive Timeout: 5 seconds

Apply configuration changes

Save all changes in the admin interface and restart Cherokee to apply the new caching and compression configuration.

sudo systemctl restart cherokee
sudo systemctl status cherokee

Cache monitoring and management

Monitor cache performance

Cherokee provides built-in statistics for monitoring cache hit rates and performance. Access these through the admin interface under Status → Information.

Key metrics to monitor include:

  • Cache hit ratio
  • Memory cache usage
  • File cache size
  • Compression ratio

Set up cache cleanup automation

Create a systemd timer to automatically clean old cache files and prevent disk space issues.

[Unit]
Description=Cherokee Cache Cleanup

[Service]
Type=oneshot
User=www-data
ExecStart=/bin/find /var/lib/cherokee/cache -type f -mtime +7 -delete
ExecStart=/bin/find /var/lib/cherokee/cache -type d -empty -delete

Create cleanup timer

Create a systemd timer to run the cache cleanup daily.

[Unit]
Description=Run Cherokee cache cleanup daily
Requires=cherokee-cache-cleanup.service

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target

Enable and start the cleanup timer:

sudo systemctl daemon-reload
sudo systemctl enable cherokee-cache-cleanup.timer
sudo systemctl start cherokee-cache-cleanup.timer

Verify your setup

Test that caching and compression are working correctly by checking response headers and performance.

# Test compression
curl -H "Accept-Encoding: gzip" -I http://localhost/

Check cache headers

curl -I http://localhost/style.css

Test Cherokee status

sudo systemctl status cherokee

View cache directory

ls -la /var/lib/cherokee/cache/

You should see headers like Content-Encoding: gzip for compressed content and appropriate Cache-Control headers for cached files.

Common issues

Symptom Cause Fix
Cache not working Incorrect directory permissions sudo chown -R www-data:www-data /var/lib/cherokee/cache
High memory usage Memory cache too large Reduce max memory usage in admin interface
Compression not applied File size below minimum threshold Adjust minimum file size in compression settings
Admin interface not accessible Firewall blocking port 9090 sudo ufw allow 9090/tcp or use cherokee-admin -b
Cache directory full No cleanup mechanism Enable the systemd timer for automated cleanup

Next steps

Running this in production?

Want this handled for you? Setting this up once is straightforward. Keeping it patched, monitored, backed up and performant across environments is the harder part. See how we run infrastructure like this for European teams.

Automated install script

Run this to automate the entire setup

Need help?

Don't want to manage this yourself?

We handle infrastructure performance optimization for businesses that depend on uptime. From initial setup to ongoing operations.