Set Up Apache as a Forward Proxy with Caching

apache-2.2cachePROXY

I would like to configure apache forward proxy with caching. I have some clients that have to downloa some big files from time to time from the internets, and I would like it to be done through this apache proxy, so that it has these big files cached on disk and returns them from cache.

I have managed to configure proxy, but caching does not work. I have cache, mem_cache, file_cache modules enabled. I have the following config of my caching proxy virtualhost:

<VirtualHost *:80>
ProxyRequests On
ProxyVia On

<Proxy *>
Order deny,allow
Deny from all
Allow from all
</Proxy>

CacheEnable disk /
CacheMaxFileSize 10000000000
CacheMinFileSize 1000000
CacheRoot "/var/cache/apache2/mod_disk_cache/"
CacheMaxExpire 24
CacheLastModifiedFactor 0.1
CacheIgnoreQueryString On
EnableSendfile On
CacheDefaultExpire 7200

CacheIgnoreNoLastMod On
CacheStorePrivate On
CacheStoreNoStore On

ServerName my-proxy

ErrorLog "/var/log/apache2/proxy-error.log"
CustomLog "/var/log/apache2/proxy-access.log" common
</VirtualHost>

For testing purposes I configured my Firefox to use this proxy. I download a zip file from
http://download.java.net/jdk8/archive/b128/binaries/jdk-8-fcs-bin-b128-linux-i586-01_feb_2014.tar.gz, which takes about 5 minutes. The only line I get in proxy-access.log on this event is:

"GET http://download.java.net/jdk8/archive/b128/binaries/jdk-8-fcs-bin-b128-linux-i586-01_feb_2014.tar.gz HTTP/1.1" 200 115883719

When I later check the /var/cache/apache2/mod_disk_cache folder, there is nothing there. And next time I download the same file it also takes the same 5 minutes, although in our local network the speed is much faster – which means it redownloads it from the internet again.

How can I make it cache?

I have seen this Setting Up Apache as a Forward Proxy with Caching question, read What Can be Cached? – there is no "Authorization" header in either request or response (checked with wireshark). So it looks to me as it should be cached. It also should not be affected by this bug, as apache version is 2.2.22-1ubuntu1 and not 2.4.3.

Best Answer

It was not initially documented properly, but CacheEnable does not implicitly apply to forward proxy anymore. there is a note and updated examples now.

http://httpd.apache.org/docs/2.4/mod/mod_cache.html#cacheenable

edit to not hide the answer in the link: as in CacheEnable disk http://