Hi, list!

I've noticed a strange behavior of mod_cache when URL is rewritten.
It caches pages, based on rewritten URL, but not original URL.
This cause that the same data is stored for different URL's, rewritten
to the same resulting URL (see the example below).
Is there a way to change this behavior and force mod_cache to cache
using the original URL?

Tested on Apache 2.2 and 2.4

Example mod_cache settings:
  CacheDefaultExpire 60
  CacheEnable disk /
  CacheIgnoreNoLastMod On
  CacheRoot /usr/local/apache24/cache

Rewrite rule (example from WordPress, Joomla, etc.):
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule .* index.php [L]

index.php
  <?php
  echo time()." ".$_SERVER['REQUEST_URI'];
  ?>

So, we have different URL's with a different content, which are
rewritten to the same script:
http://example.com/foo/ --> /index.php
http://example.com/bar/ --> /index.php
etc.

Web server will serve the same cached content for both URL's.
I see it in browser and in logs.

Accessing the first cached URL:
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH00698: cache: Key for entity /foo/?(null) is
http://example.com:80/foo/?
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH00750: Adding CACHE_SAVE filter for /foo/
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH00751: Adding CACHE_REMOVE_URL filter for /foo/
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH01626: authorization result of Require all
granted: granted
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH01626: authorization result of <RequireAny>:
granted
* and suddenly! *
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH00698: cache: Key for entity /index.php?(null) is
http://example.com:80/index.php?
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH00709: Recalled cached URL info header
http://example.com:80/index.php?
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH00720: Recalled headers for URL
http://example.com:80/index.php?
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH00763: cache: running CACHE_OUT filter
[Thu Apr 18 14:01:30 2013] example.com [debug] [client
11.22.33.44:11702] AH00764: cache: serving /index.php

And the second one:
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH00698: cache: Key for entity /bar/?(null) is
http://example.com:80/bar/?
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH00750: Adding CACHE_SAVE filter for /bar/
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH00751: Adding CACHE_REMOVE_URL filter for /bar/
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH01626: authorization result of Require all
granted: granted
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH01626: authorization result of <RequireAny>:
granted
* and again! *
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH00698: cache: Key for entity /index.php?(null) is
http://example.com:80/index.php?
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH00709: Recalled cached URL info header
http://example.com:80/index.php?
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH00720: Recalled headers for URL
http://example.com:80/index.php?
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH00763: cache: running CACHE_OUT filter
[Thu Apr 18 14:01:36 2013] example.com [debug] [client
11.22.33.44:58307] AH00764: cache: serving /index.php

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org

Reply via email to