Bug 45273 - mod_dir bypasses mod_cache
Summary: mod_dir bypasses mod_cache
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_dir (show other bugs)
Version: 2.2.9
Hardware: Other Linux
: P2 major (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
: 45347 51057 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-06-24 16:34 UTC by Adriano Nagel
Modified: 2011-04-22 18:53 UTC (History)
3 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adriano Nagel 2008-06-24 16:34:36 UTC
Requests handled by mod_dir are not cached. Examples below.


1) Cached request:

$ curl -s http://localhost/index.html > /dev/null
$ curl -I http://localhost/index.html
HTTP/1.1 200 OK
Date: Tue, 24 Jun 2008 23:19:41 GMT
Server: Apache/2.2.9 (Unix)
Last-Modified: Mon, 09 Jun 2008 13:16:13 GMT
ETag: "481a3-10c0-44f3b9d9fc140"
Accept-Ranges: bytes
Content-Length: 4288
Cache-Control: max-age=120
Expires: Tue, 24 Jun 2008 23:21:28 GMT
Age: 13
Content-Type: text/html


2) Uncached request (via mod_dir):

$ curl -s http://localhost/ > /dev/null
$ curl -I http://localhost/
HTTP/1.1 200 OK
Date: Tue, 24 Jun 2008 23:22:39 GMT
Server: Apache/2.2.9 (Unix)
Last-Modified: Mon, 09 Jun 2008 13:16:13 GMT
ETag: "481a3-10c0-44f3b9d9fc140"
Accept-Ranges: bytes
Content-Length: 4288
Cache-Control: max-age=120
Expires: Tue, 24 Jun 2008 23:24:39 GMT
Content-Type: text/html


Some snippets of the httpd.conf file:

---------------------------------

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

    ExpiresActive On

    <Files ~ "^index.html$">
         ExpiresDefault A120
    </Files>
</Directory>

CacheRoot   /var/cache/apache/
CacheEnable disk /
CacheDirLevels 2
CacheDirLength 1

CacheIgnoreCacheControl On

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

---------------------------------
Comment 1 Ruediger Pluem 2008-07-06 06:21:27 UTC
*** Bug 45347 has been marked as a duplicate of this bug. ***
Comment 2 duchuanying 2010-03-08 11:26:10 UTC
In mod_dir,  used ap_internal_fast_redirect, so  CACHE_SAVE filter is not executed. 

mod_dir use fast_redirect only when the file is local static file. 

        if (rr->status == HTTP_OK
            && (   (rr->handler && !strcmp(rr->handler, "proxy-server"))
                || rr->finfo.filetype == APR_REG)) {
            ap_internal_fast_redirect(rr, r); 
            return OK; 
        }
Comment 3 duchuanying 2010-03-08 11:28:01 UTC
In mod_dir,  used ap_internal_fast_redirect, so  CACHE_SAVE filter is not executed. 

mod_dir use fast_redirect only when the file is local static file. 

        if (rr->status == HTTP_OK
            && (   (rr->handler && !strcmp(rr->handler, "proxy-server"))
                || rr->finfo.filetype == APR_REG)) {
            ap_internal_fast_redirect(rr, r); 
            return OK; 
        }
Comment 4 Geoff Millikan 2011-04-13 18:19:52 UTC
As described on duplicate Bug 51057, this bug produces a significant loss of functionality for example:

This URL is cached (because the DirectoryIndex of mod_dir is not being used):
http://www.my-company.com/index.php

This URL is _not_ cached because it is using the DirectoryIndex directive:
http://www.my-company.com/

The "home page" of a web site is frequently visited.  And it's not getting cached.  This is a significant loss of functionality mod_disk_cache is desired to provide.
Comment 5 Eric Covener 2011-04-13 20:41:25 UTC
*** Bug 51057 has been marked as a duplicate of this bug. ***
Comment 6 Ruediger Pluem 2011-04-14 02:28:42 UTC
This should be fixed in the latest 2.2.x release. Can you please test?
Comment 7 Geoff Millikan 2011-04-22 18:53:39 UTC
Yes, in production release of 2.2.17 I confirm it's fixed.  I compiled from source for CentOS 5.6.

---== Details ==---
# cat /etc/*release*
CentOS release 5.6 (Final)

#uname -a 
OS: Linux 2.6.18-238.5.1.el5 #1 SMP Fri Apr 1 18:41:58 EDT 2011 x86_64

# /usr/local/apache2/bin/httpd -V
Server version: Apache/2.2.17 (Unix)
Server built:   Apr 22 2011 21:56:30
Server's Module Magic Number: 20051115:25
Server loaded:  APR 1.4.2, APR-Util 1.3.10
Compiled using: APR 1.4.2, APR-Util 1.3.10
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=2
 -D HTTPD_ROOT="/usr/local/apache2"
 -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

---== Configure statement ==---
./configure --prefix="/usr/local/apache2" CFLAGS="-DDYNAMIC_MODULE_LIMIT=2 -DDEFAULT_PIDLOG=\"run/httpd.pid\"" --disable-imagemap --disable-userdir --disable-asis --disable-actions --disable-authn-default --disable-authz-groupfile --disable-authz-default --disable-filter --disable-negotiation --disable-version --disable-cgi --enable-autoindex --enable-cache --enable-expires=shared --enable-disk-cache --enable-deflate --enable-headers --enable-info=shared --enable-rewrite --enable-ssl --enable-proxy --disable-proxy-balancer --disable-proxy-ftp --disable-proxy-scgi --disable-proxy-ajp --disable-proxy-balancer --enable-reqtimeout --enable-vhost-alias --enable-mime --with-mpm=prefork