Caching images with apache reverse proxy

apache-2.2cachereverse-proxy

I'm trying to set up an apache2 reverse proxy to cache images. (Apache, not nginx required)

There appear to be headers being cached, but not images,css etc.

My config:

CacheEnable disk /
CacheDirLevels 5
CacheDirLength 3

Header unset Cache-Control
CacheIgnoreNoLastMod On
CacheIgnoreCacheControl On
CacheMaxFileSize 100000000
CacheIgnoreNoLastMod On
CacheMaxExpire 1209600
CacheIgnoreQueryString On
ExpiresActive On
ExpiresByType image/gif A600
ExpiresByType image/png A600
ExpiresByType image/jpeg A600
ExpiresByType text/css A600
ExpiresByType text/javascript A600
ExpiresByType application/x-javascript A600
ExpiresByType image/x-icon A600


find /var/cache/apache2/mod_disk_cache
/var/cache/apache2/mod_disk_cache/yLp
/var/cache/apache2/mod_disk_cache/yLp/RoH
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ/uhEhPIw.header
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ/uhEhPIw.header.vary
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ/uhEhPIw.header.vary/E8t
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ/uhEhPIw.header.vary/E8t/g9u
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ/uhEhPIw.header.vary/E8t/g9u/8de
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ/uhEhPIw.header.vary/E8t/g9u/8de/VLu
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ/uhEhPIw.header.vary/E8t/g9u/8de/VLu/3Io
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ/uhEhPIw.header.vary/E8t/g9u/8de/VLu/3Io/qHld08w.data
/var/cache/apache2/mod_disk_cache/yLp/RoH/iGt/8Dm/4KZ/uhEhPIw.header.vary/E8t/g9u/8de/VLu/3Io/qHld08w.header

find /var/cache/apache2/mod_disk_cache|grep jpeg
& find /var/cache/apache2/mod_disk_cache|grep css
result in nothing.

From error log (debug)
[Sun Apr 28 14:22:36 2013] [debug] mod_cache.c(751): cache: Caching url: /~/media/Images/2011_01_LR_jpg.jpg
[Sun Apr 28 14:22:36 2013] [debug] mod_cache.c(757): cache: Removing CACHE_REMOVE_URL filter.

Best Answer

I think mod_cache doesn't work out of the box, so you should tweak your apache httpd config or
vhost config: First on the Directory where the static files are located you would want to set:

    <FilesMatch "\\.(|pdf|jpg|jpeg|png|gif|)$"> 
    Header unset Last-Modified 
    </FilesMatch> 

Also in your cache_mod config as far as I remember you need to specify CacheRoot path:

    CacheRoot /path/to/your/cache_folder

Hope this helps.