I'm using Apache Web server in a Docker container as a Cache Reverse Proxy. The version is
Server version: Apache/2.4.10 (Debian)
Server built: Nov 28 2015 14:05:48
The following modules are activated:
/usr/sbin/a2enmod proxy proxy_http
/usr/sbin/a2enmod rewrite
/usr/sbin/a2enmod cache
/usr/sbin/a2enmod cache_disk
mod_cache is configured in etc/apache2/mods-enabled/cache_disk.conf with
<IfModule mod_cache_disk.c>
CacheRoot /var/cache/apache2/mod_cache_disk
CacheEnable disk /
CacheDirLevels 2
CacheDirLength 1
</IfModule>
In /etc/apache2/sites-enabled/000-default.conf, the reverse proxy behavior is configured with rewriting the URL:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
LogLevel debug rewrite:trace3
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteRule ^(.*)test$ http://192.168.99.100:8080$1geo [P]
ProxyPass / http://192.168.99.100:8080/
ProxyPassReverse / http://192.168.99.100:8080/
</VirtualHost>
My goal is to cache rewritten URLs. In this case /samplecache/test should be treated the same as /samplecache/geo and only cached once because the response is the same. But it seems that mod_cache always takes the request URL not the rewritten URL, i.e. the calls
curl -v http://192.168.99.100:8090/samplecache/test
curl -v http://192.168.99.100:8090/samplecache/geo
deliver the same result from the backend but they are cached twice. I can see in in the error.log that /sample/test is tacken as cache key instead of the rewritten /samplecache/geo:
[Sun May 01 16:17:05.351716 2016] [cache:debug] [pid 9:tid 139956735403776] mod_cache.c(1332): [client 192.168.99.1:52687] AH00769: cache: Caching url: /samplecache/test
[Sun May 01 16:17:05.352121 2016] [cache_disk:debug] [pid 9:tid 139956735403776] mod_cache_disk.c(1350): [client 192.168.99.1:52687] AH00737: commit_entity: Headers and body for URL http://192.168.99.100:8090/samplecache/test? cached.
How can I use a rewritten URL as cache key, so that it is only cached once.