You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Marko Asplund <ma...@ixonos.com> on 2007/12/06 21:56:17 UTC
[users@httpd] Reverse proxy cache control problems
hi
I'm trying to cache dynamically generated content using an Apache 2.2
reverse proxy.
Apache proxies content coming from Tomcat through AJP protocol.
For some reason mod_cache determines that cacheable content is not fresh
and refetches the content
though the application sets the Expires and Cache-Control HTTP response
headers (see below).
I'd like to be able to always cache cacheable pages for a certain period
of time without any further freshness validation
and force non-cacheable pages to be excluded from caching.
How should I set the response headers and configure mod_cache in order
to do that?
Marko
Here's a debug log extract from a page load:
[Thu Dec 06 22:25:35 2007] [debug] mod_disk_cache.c(477): disk_cache:
Recalled cached URL info header
http://localhost:5050/cachetest/jsp/cacheable/main.jsp?
[Thu Dec 06 22:25:35 2007] [debug] mod_disk_cache.c(750): disk_cache:
Recalled headers for URL
http://localhost:5050/cachetest/jsp/cacheable/main.jsp?
[Thu Dec 06 22:25:35 2007] [debug] cache_storage.c(272): Cached response
for /cachetest/jsp/cacheable/main.jsp isn't fresh. Adding/replacing
conditional request headers.
[Thu Dec 06 22:25:35 2007] [debug] mod_cache.c(129): Adding CACHE_SAVE
filter for /cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] mod_cache.c(136): Adding
CACHE_REMOVE_URL filter for /cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(44): proxy: AJP:
canonicalising URL //127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(1378): [client
127.0.0.1] proxy: ajp: found worker ajp://127.0.0.1:8009/cachetest for
ajp://127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy.c(777): Running scheme ajp
handler (attempt 0)
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_http.c(1652): proxy: HTTP:
declining URL ajp://127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(507): proxy: AJP:
serving URL ajp://127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(1798): proxy: AJP: has
acquired connection for (127.0.0.1)
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(1859): proxy: connecting
ajp://127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp to 127.0.0.1:8009
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(1955): proxy: connected
/cachetest/jsp/cacheable/main.jsp to 127.0.0.1:8009
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(2050): proxy: AJP: fam 2
socket created to connect to 127.0.0.1
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(218): Into
ajp_marshal_into_msgb
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[0] [Host] = [localhost:5050]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[1] [User-Agent] = [Mozilla/5.0 (X11; U;
Linux i686; en-US; rv:1.9b1) Gecko/2007110903 Firefox/3.0b1]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[2] [Accept] =
[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[3] [Accept-Language] = [en-us,en;q=0.5]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[4] [Accept-Encoding] = [gzip,deflate]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[5] [Accept-Charset] =
[ISO-8859-1,utf-8;q=0.7,*;q=0.7]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[6] [Keep-Alive] = [300]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[7] [Connection] = [keep-alive]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[8] [Cookie] =
[JSESSIONID=4ACF4EDC4DCBC6253DE8F810598F0771; SCREEN_NAME=iscdwJTOWtk=;
LOGIN=test@liferay.com; COOKIE_SUPPORT=true; GUEST_LANGUAGE_ID=fi_FI]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[9] [Cache-Control] = [max-age=0]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[10] [Max-Forwards] = [10]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(424):
ajp_marshal_into_msgb: Done
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(188): proxy:
APR_BUCKET_IS_EOS
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(193): proxy: data to
read (max 8186 at 4)
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(208): proxy: got 0
bytes of data
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(643): ajp_read_header:
ajp_ilink_received 04
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(653): ajp_parse_type: got 04
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(484):
ajp_unmarshal_response: status = 200
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(495):
ajp_unmarshal_response: Number of headers is = 4
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(557):
ajp_unmarshal_response: Header[0] [Expires] = [Fri, 7 Dec 2007 14:19:41 GMT]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(557):
ajp_unmarshal_response: Header[1] [Cache-Control] = [max-age=3600]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(557):
ajp_unmarshal_response: Header[2] [Content-Type] = [text/html;charset=UTF-8]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(567):
ajp_unmarshal_response: ap_set_content_type done
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(557):
ajp_unmarshal_response: Header[3] [Content-Length] = [341]
...
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] Reverse proxy cache control problems
Posted by Axel-Stephane SMORGRAV <Ax...@europe.adp.com>.
Could you possibly post the headers returned by http://localhost:5050/cachetest/jsp/cacheable/main.jsp along with your proxy configuration directives?
The request headers could also be relevant. If you use Mozilla Firefox, you can obtain these headers using the add-on LiveHTTPHeaders.
-ascs
____________________________________________
-----Message d'origine-----
De : Marko Asplund [mailto:marko.asplund@ixonos.com]
Envoyé : jeudi 6 décembre 2007 21:56
À : users@httpd.apache.org
Objet : [users@httpd] Reverse proxy cache control problems
hi
I'm trying to cache dynamically generated content using an Apache 2.2
reverse proxy.
Apache proxies content coming from Tomcat through AJP protocol.
For some reason mod_cache determines that cacheable content is not fresh
and refetches the content
though the application sets the Expires and Cache-Control HTTP response
headers (see below).
I'd like to be able to always cache cacheable pages for a certain period
of time without any further freshness validation
and force non-cacheable pages to be excluded from caching.
How should I set the response headers and configure mod_cache in order
to do that?
Marko
Here's a debug log extract from a page load:
[Thu Dec 06 22:25:35 2007] [debug] mod_disk_cache.c(477): disk_cache:
Recalled cached URL info header
http://localhost:5050/cachetest/jsp/cacheable/main.jsp?
[Thu Dec 06 22:25:35 2007] [debug] mod_disk_cache.c(750): disk_cache:
Recalled headers for URL
http://localhost:5050/cachetest/jsp/cacheable/main.jsp?
[Thu Dec 06 22:25:35 2007] [debug] cache_storage.c(272): Cached response
for /cachetest/jsp/cacheable/main.jsp isn't fresh. Adding/replacing
conditional request headers.
[Thu Dec 06 22:25:35 2007] [debug] mod_cache.c(129): Adding CACHE_SAVE
filter for /cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] mod_cache.c(136): Adding
CACHE_REMOVE_URL filter for /cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(44): proxy: AJP:
canonicalising URL //127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(1378): [client
127.0.0.1] proxy: ajp: found worker ajp://127.0.0.1:8009/cachetest for
ajp://127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy.c(777): Running scheme ajp
handler (attempt 0)
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_http.c(1652): proxy: HTTP:
declining URL ajp://127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(507): proxy: AJP:
serving URL ajp://127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(1798): proxy: AJP: has
acquired connection for (127.0.0.1)
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(1859): proxy: connecting
ajp://127.0.0.1:8009/cachetest/jsp/cacheable/main.jsp to 127.0.0.1:8009
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(1955): proxy: connected
/cachetest/jsp/cacheable/main.jsp to 127.0.0.1:8009
[Thu Dec 06 22:25:35 2007] [debug] proxy_util.c(2050): proxy: AJP: fam 2
socket created to connect to 127.0.0.1
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(218): Into
ajp_marshal_into_msgb
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[0] [Host] = [localhost:5050]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[1] [User-Agent] = [Mozilla/5.0 (X11; U;
Linux i686; en-US; rv:1.9b1) Gecko/2007110903 Firefox/3.0b1]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[2] [Accept] =
[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[3] [Accept-Language] = [en-us,en;q=0.5]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[4] [Accept-Encoding] = [gzip,deflate]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[5] [Accept-Charset] =
[ISO-8859-1,utf-8;q=0.7,*;q=0.7]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[6] [Keep-Alive] = [300]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[7] [Connection] = [keep-alive]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[8] [Cookie] =
[JSESSIONID=4ACF4EDC4DCBC6253DE8F810598F0771; SCREEN_NAME=iscdwJTOWtk=;
LOGIN=test@liferay.com; COOKIE_SUPPORT=true; GUEST_LANGUAGE_ID=fi_FI]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[9] [Cache-Control] = [max-age=0]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(284):
ajp_marshal_into_msgb: Header[10] [Max-Forwards] = [10]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(424):
ajp_marshal_into_msgb: Done
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(188): proxy:
APR_BUCKET_IS_EOS
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(193): proxy: data to
read (max 8186 at 4)
[Thu Dec 06 22:25:35 2007] [debug] mod_proxy_ajp.c(208): proxy: got 0
bytes of data
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(643): ajp_read_header:
ajp_ilink_received 04
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(653): ajp_parse_type: got 04
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(484):
ajp_unmarshal_response: status = 200
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(495):
ajp_unmarshal_response: Number of headers is = 4
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(557):
ajp_unmarshal_response: Header[0] [Expires] = [Fri, 7 Dec 2007 14:19:41 GMT]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(557):
ajp_unmarshal_response: Header[1] [Cache-Control] = [max-age=3600]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(557):
ajp_unmarshal_response: Header[2] [Content-Type] = [text/html;charset=UTF-8]
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(567):
ajp_unmarshal_response: ap_set_content_type done
[Thu Dec 06 22:25:35 2007] [debug] ajp_header.c(557):
ajp_unmarshal_response: Header[3] [Content-Length] = [341]
...
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org