You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2015/07/14 14:16:28 UTC
[Bug 58135] New: mod_cache sends client "if-Modified-Since" to
backend even when a more recent version is in cache
https://bz.apache.org/bugzilla/show_bug.cgi?id=58135
Bug ID: 58135
Summary: mod_cache sends client "if-Modified-Since" to backend
even when a more recent version is in cache
Product: Apache httpd-2
Version: 2.4.12
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: mod_cache
Assignee: bugs@httpd.apache.org
Reporter: barth.alexander@gmail.com
Created attachment 32903
--> https://bz.apache.org/bugzilla/attachment.cgi?id=32903&action=edit
error.log at debug level
I have a python script which generates dynamic web pages and I want to use
mod_cache (and mod_cache_disk) to speed up the access to this page. The python
program uses the "If-Modified-Since", "Last-Modified" and the "Cache-Control"
headers. Revalidation is very fast for the python program, therefore I set the
response header
"Cache-Control" to "must-revalidate, max-age=5".
mod_cache works as expected as long as the client does not send itself the
"If-Modified-Since" header. In my tests below, mod_cache has cached version of
an URL (Last-Modified: Mon, 13 Jul 2015 07:33:49 GMT). The client tries the
revalidate a stale version (If-Modified-Since: Thu, 09 Jul 2015 20:26:45 GMT).
The problem is that mod_cache ask to the python script if the version from the
9 July can be revalidate (instead of its own more recent version from the 13
July).
In my set-up, the client always send the "If-Modified-Since" header and
therefore the cached version from mod_cache is (almost) never used. I am
wondering if mod_cache should not try to revalidate to most recent version
(either from client or from cache).
I have tried apache 2.4.10 and 2.4.12 (in a docker container based on ubuntu
15.04). The tests I made were performed inside the container. For what is
worth, I include my configurations files (cache_disk.conf and
000-default.conf).
Any help would be greatly appreciated.
## empty cache
# htcacheclean -p /var/cache/apache2/mod_cache_disk -r -l 1
## verify that cache is empty
# htcacheclean -p /var/cache/apache2/mod_cache_disk -A
## make first request
# curl --verbose
'http://localhost/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0'
> out
* Connected to localhost (::1) port 80 (#0)
> GET /Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0 HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 14 Jul 2015 06:34:42 GMT
* Server Apache/2.4.10 (Ubuntu) is not blacklisted
< Server: Apache/2.4.10 (Ubuntu)
< Last-Modified: Mon, 13 Jul 2015 07:33:49 GMT
< Vary: Accept-Encoding
< X-Cache: MISS from 172.17.1.37
< X-Cache-Detail: "cache miss: attempting entity save" from 172.17.1.37
< Transfer-Encoding: chunked
< Content-Type: text/xml
<
## verify that first request is cached
# htcacheclean -p /var/cache/apache2/mod_cache_disk -A
http://localhost:80/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0
422 3697448 200 0 1436855683140502 1436855688140502 1436855682866721
1436855683140502 1 0
## make second request (after 5 seconds)
# curl --verbose
'http://localhost/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0'
> out
* Hostname was NOT found in DNS cache
* Connected to localhost (::1) port 80 (#0)
> GET /Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0 HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 14 Jul 2015 06:34:59 GMT
* Server Apache/2.4.10 (Ubuntu) is not blacklisted
< Server: Apache/2.4.10 (Ubuntu)
< Last-Modified: Mon, 13 Jul 2015 07:33:49 GMT
< Vary: Accept-Encoding
< Cache-Control: must-revalidate, max-age=5
< X-Cache: REVALIDATE from 172.17.1.37
< X-Cache-Detail: "conditional cache hit: entity refreshed" from 172.17.1.37
< Content-Length: 3697448
< Content-Type: text/xml
<
## Yah! Cache is revalitated
# htcacheclean -p /var/cache/apache2/mod_cache_disk -A
http://localhost:80/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0
472 3697448 200 0 1436855699443390 1436855704443390 1436855699441708
1436855699443390 1 0
## Make request when the users sends a "If-Modified-Since" header. Client
(curl) has a stale copy, but the more recient version of the mod_cache can be
revalidated.
# curl --verbose
'http://localhost/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0'
-H 'If-Modified-Since: Thu, 09 Jul 2015 20:26:45 GMT' > out
* Connected to localhost (::1) port 80 (#0)
> GET /Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0 HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost
> Accept: */*
> If-Modified-Since: Thu, 09 Jul 2015 20:26:45 GMT
>
< HTTP/1.1 200 OK
< Date: Tue, 14 Jul 2015 06:35:32 GMT
* Server Apache/2.4.10 (Ubuntu) is not blacklisted
< Server: Apache/2.4.10 (Ubuntu)
< Last-Modified: Mon, 13 Jul 2015 07:33:49 GMT
< Vary: Accept-Encoding
< X-Cache: MISS from 172.17.1.37
< X-Cache-Detail: "cache miss: attempting entity save" from 172.17.1.37
< Transfer-Encoding: chunked
< Content-Type: text/xml
## Unfortunatetly, a cache miss.
root@1ce49e006c40:/var/oceanbrowser# cat
/etc/apache2/mods-enabled/cache_disk.conf
<IfModule mod_cache_disk.c>
# This path must be the same as the one in /etc/default/apache2
CacheRoot /var/cache/apache2/mod_cache_disk
# Enable the X-Cache header
CacheHeader on
# Enable the X-Cache-Detail header
CacheDetailHeader on
# The maximum size (in bytes) of a document to be placed in the cache
# GetCapabilities can be quite large, maximum here is 10 MB
CacheMaxFileSize 10000000
# The result of CacheDirLevels * CacheDirLength must not be higher than
# 20. Moreover, pay attention on file system limits. Some file systems
# do not support more than a certain number of inodes and
# subdirectories (e.g. 32000 for ext3)
CacheDirLevels 2
CacheDirLength 1
</IfModule>root@1ce49e006c40:/var/oceanbrowser# cat
/etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
# For debugging
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Enable cache
<IfModule mod_cache.c>
CacheEnable disk /
</IfModule>
CustomLog ${APACHE_LOG_DIR}/cache-access.log common
CustomLog ${APACHE_LOG_DIR}/cache-cached-requests.log common
env=cache-hit
CustomLog ${APACHE_LOG_DIR}/cache-uncached-requests.log common
env=cache-miss
CustomLog ${APACHE_LOG_DIR}/cache-revalidated-requests.log common
env=cache-revalidate
CustomLog ${APACHE_LOG_DIR}/cache-invalidated-requests.log common
env=cache-invalidate
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/oceanbrowser/apache>
Require all granted
</Directory>
WSGIDaemonProcess gher-diva.phys.ulg.ac.be processes=8 threads=15
WSGIProcessGroup gher-diva.phys.ulg.ac.be
WSGIScriptAlias / /var/oceanbrowser/apache/divaonweb.wsgi
WSGIApplicationGroup %{GLOBAL}
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 58135] mod_cache sends client "if-Modified-Since" to backend
even when a more recent version is in cache
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58135
--- Comment #2 from Alexander Barth <ba...@gmail.com> ---
(In reply to Yishuai Li from comment #1)
> > I am wondering if mod_cache should not try to revalidate to most recent
> > version (either from client or from cache).
> Doesn't that contradict with your configuration?
I do not see why this should contradict with my configuration. Apache has a
more recent version in its cache, why should it check if a more ancient version
from the client is still valid. But sadly, I don't use Apache anymore for this
project. It turned out that nginx has exactly the right behavior for me in this
case.
I still use Apache in other use-cases, and I am grateful for the fine work of
the developers.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 58135] mod_cache sends client "if-Modified-Since" to backend
even when a more recent version is in cache
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58135
--- Comment #1 from Yishuai Li <yi...@upenn.edu> ---
> I am wondering if mod_cache should not try to revalidate to most recent
> version (either from client or from cache).
Doesn't that contradict with your configuration?
> Revalidation is very fast for the python program, therefore I set the response
> header "Cache-Control" to "must-revalidate, max-age=5".
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org