Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Reverse Caching Proxy - why isn't it caching?

I am attempting to set up a reverse caching proxy for ad graphics (GIF, JPEG, SWF) serving. The proxying is working fine and sending the request on to the origin server, but I can’t seem to figure out why the content isn't being cached. My current config is below. The goal is to cache all requests that match the /ca/ URI prefix. The origin server is serving the files with clean URLs, no file extensions, Cache-control max-age=1 week set on the origin server headers.

ProxyRequests Off
<Proxy *>
 Order deny,allow
 Allow from all
</Proxy>
<IfModule mod_disk_cache.c>
 CacheEnable disk /
 CacheRoot "/var/cache/mod_proxy"
 CacheDirLevels 3
 CacheDirLength 5
 CacheIgnoreCacheControl On 
</IfModule>

RewriteCond %{REQUEST_URI} ^/ca/*
RewriteRule ^/(.*)$ http://origin.webserver.com/$1 [P,L]

Currently, the only caching I’ve seen actually happen is that of local files accessed on the proxy servers, I’m looking for what I’m missing to get content fetched from the origin server to be cached.

I’m wondering if it has to do with mod_cache not caching because the content is fetched from the origin server, and not on a location on disk.

I am looking for a way to force all requests matching that prefix to be cached.

P.S. It looks like I’m having this exact issue: http://mail-archives.apache.org/mod_mbox/httpd-users/200901.mbox/%[email protected]%3E. I will be checking my permissions and go over debug messages…

like image 885
notbrain Avatar asked Jun 17 '09 19:06

notbrain


People also ask

Do proxies cache?

Proxy caching is a feature of proxy servers that stores content on the proxy server itself, allowing web services to share those resources to more users. The proxy server coordinates with the source server to cache documents such as files, images and web pages.

What does a HTTP caching proxy do if it has a cache miss?

Second, a caching proxy often functions as a second (or higher) level cache, getting only the misses left over from Web clients that use a per-client cache (e.g., Mosaic and Netscape). The misses passed to the proxy-server from the client usually do not contain a document requested twice by the same user.


1 Answers

Adding these directives seemed to kick the cache mechanism into gear. I figure it has to do with expiration and cache-control headers as sent from the origin server since I'm serving up images with Symfony/PHP5 instead of directly from the filesystem.

<IfModule mod_disk_cache.c>
    CacheEnable disk /
    CacheRoot "/var/cache/mod_proxy"
    CacheDirLevels 3
    CacheDirLength 5
    CacheIgnoreCacheControl On
    CacheMaxFileSize 100000000
    CacheIgnoreNoLastMod On
    CacheMaxExpire 1209600
    CacheIgnoreQueryString On
</IfModule>
like image 99
notbrain Avatar answered Sep 27 '22 18:09

notbrain