mod_cache lets Apache cache responses in memory or on disk, serving repeat requests without regenerating them — genuinely useful for reducing load on a slow backend or database-heavy application.
<IfModule mod_cache.c>
CacheQuickHandler on
CacheLock on
<IfModule mod_cache_disk.c>
CacheRoot /var/cache/apache2/mod_cache_disk
CacheEnable disk /
CacheDirLevels 2
CacheDirLength 1
</IfModule>
CacheDefaultExpire 3600
CacheIgnoreHeaders Set-Cookie
</IfModule>
sudo a2enmod cache cache_disk sudo systemctl reload apache2
Respect Cache-Control From Your Backend
mod_cache respects standard HTTP caching headers (Cache-Control, Expires) from your application by default — setting appropriate cache headers in your application code (not just the Apache config) is what actually determines what gets cached and for how long, rather than the Apache config alone.