Cache Optimizer
Web server and application cache optimization tool for improving performance and reducing server load.
Cache Optimizer
A comprehensive tool for optimizing and managing web server caching mechanisms, including FastCGI and Redis caching.
Features
- FastCGI cache configuration
- Redis cache optimization
- Cache performance analysis
- Cache monitoring and reporting
- Multi-layer caching support
- Cache warming capabilities
Installation
Prerequisites
- Bash shell
- Python 3 (for dashboard)
- jq (for JSON processing)
- yq (for YAML processing, optional)
- Root or sudo privileges
Installation Steps
- Clone the repository:
git clone https://github.com/yourusername/lambda-scripts.git cd lambda-scripts/admin-tools
- Make the script executable:
chmod +x cache-optimizer.sh
- Install dependencies:
For Debian/Ubuntu:
sudo apt-get update sudo apt-get install -y python3 jq redis-server
For RHEL/CentOS:
sudo yum install -y python3 jq redis
- Download the script from the Lambda Softworks Customer Portal:
- Log in to your Lambda Softworks Customer Portal account
- Navigate to the Files section
- Download the cache-optimizer.sh script
Usage
Basic Commands
- Setup FastCGI cache:
sudo ./cache-optimizer.sh --setup-fastcgi
- Optimize Redis:
sudo ./cache-optimizer.sh --optimize-redis
- Monitor cache performance:
sudo ./cache-optimizer.sh --monitor 60 3600
Advanced Options
--analyze
: Analyze cache performance--clear TYPE
: Clear specified cache (fastcgi,redis,all)--monitor [interval] [duration]
: Monitor cache performance
Configuration
Cache Configuration
# /etc/web-tools/cache-config.yml redis: maxmemory: 2gb maxmemory_policy: allkeys-lru save_frequency: 900 appendonly: true appendfsync: everysec fastcgi: cache_path: /var/cache/nginx cache_levels: 1:2 cache_valid: 60m cache_min_uses: 1
Logs and Data Storage
Log File Location
/var/log/web-tools/cache-optimizer.log
Cache Locations
- FastCGI Cache:
/var/cache/nginx
- Redis Data:
/var/lib/redis
Backup Location
/etc/web-tools/cache-backups/
Report Location
/var/log/web-tools/cache-reports/
Cross-Platform Compatibility
Linux Support
- RHEL/CentOS 7+
- Ubuntu 18.04+
- Debian 10+
- Other Linux distributions with systemd
Service Support
- Nginx 1.18+
- Redis 6.0+
Examples
Cache Setup
# Setup FastCGI cache sudo ./cache-optimizer.sh --setup-fastcgi # Optimize Redis sudo ./cache-optimizer.sh --optimize-redis
Cache Management
# Analyze cache performance sudo ./cache-optimizer.sh --analyze # Clear specific cache sudo ./cache-optimizer.sh --clear fastcgi sudo ./cache-optimizer.sh --clear redis # Monitor cache performance sudo ./cache-optimizer.sh --monitor 300 7200
Troubleshooting
Common Issues
Permission Errors
- Ensure the script is run with sudo
- Check directory permissions
- Verify user has necessary privileges
Cache Issues
- Verify cache directory permissions
- Check cache size limits
- Review cache configuration
Report Generation Issues
- Check log directory permissions
- Verify HTML template access
- Check disk space
Debug Mode
To enable debug logging:
sudo DEBUG=1 ./cache-optimizer.sh [OPTIONS]