Setting Up Apache as a Forward Proxy with Cahcing

Posted by Karl on Server Fault See other posts from Server Fault or by Karl
Published on 2012-11-13T16:59:18Z Indexed on 2012/11/13 17:02 UTC
Read the original article Hit count: 415

Filed under:
|
|

I am trying to set up Apache as a forward proxy with caching, but it does not seem to be working correctly. Getting Apache working as a forward proxy was no problem, but no matter what I do it is not caching anything, to disk or memory. I already checked to make sure nothing is conflicting in the mods_enabled directory with mod_cache (ended up commenting it all out) and also I tried moving all of the caching related fields to the configuration file for mod_cache. In addition I set up logging for caching requests, but nothing is being written to those logs. Below is my Apache config, any help would be greatly appreciated!!

<VIRTUALHOST *:8080>
ProxyRequests On
ProxyVia On
#ErrorLog "/var/log/apache2/proxy-error.log"
#CustomLog "/var/log/apache2/proxy-access.log" common
CustomLog "/var/log/apache2/cached-requests.log" common env=cache-hit
CustomLog "/var/log/apache2/uncached-requests.log" common env=cache-miss
CustomLog "/var/log/apache2/revalidated-requests.log" common env=cache-revalidate
CustomLog "/var/log/apache2/invalidated-requests.log" common env=cache-invalidate
LogFormat "%{cache-status}e ..."

        # This path must be the same as the one in /etc/default/apache2
        CacheRoot /var/cache/apache2/mod_disk_cache

        # This will also cache local documents. It usually makes more sense to
        # put this into the configuration for just one virtual host.

        CacheEnable disk /
        #CacheHeader on
        CacheDirLevels 3
        CacheDirLength 5
##<IfModule mod_mem_cache.c>
#        CacheEnable mem /
#        MCacheSize 4096
#        MCacheMaxObjectCount 100
#        MCacheMinObjectSize 1
#        MCacheMaxObjectSize 2048
#</IfModule>


<Proxy *>
Order deny,allow
Deny from all
Allow from x.x.x.x
#IP above hidden for this post

<filesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "proxy-revalidate"
</filesMatch>

</Proxy>
</VIRTUALHOST>

Thank you once again!

© Server Fault or respective owner

Related posts about apache2

Related posts about proxy