0

I have one local Apache instance running with mod_cache (+ disk & mem) enabled, and it seems to cache content from my appserver fine. My app server sets Expiration headers and Last-modified. Yet, when deploying on a production server with the same modules enabled, I am getting the following error in my logs: blablabla not cached. Reason: Query string present but no explicit expiration time. A section from debug logs being output when calling a service is appended at the end of this post

Any clues on why Apache is not caching content? The only difference I can tell is the Apache version. Locally I am running 2.2.22, in production 2.2.11.

This is from my config

ServerName my-front-end.server.com
CacheEnable mem /
<Location "/rest-api/myservice" >
            ProxyPass           http://my-backend.appserver.com:8180/rest-api/myservice
            ProxyPassReverse    http://my-backend.appserver.com:8180/rest-api/myservice
</Location>

This is example output

< HTTP/1.1 200 OK
< Date: Mon, 19 Nov 2012 16:09:13 GMT
< Server: Sun GlassFish Enterprise Server v2.1.1
< X-Powered-By: Servlet/2.5
< Expires: Tue Nov 20 05:00:00 CET 2012
< Last-Modified: Mon Nov 19 17:09:13 CET 2012
< Cache-Control: no-transform
< Content-Type: application/x-javascript
< Transfer-Encoding: chunked

This is from my apache log (changed server names and app uri):

[Tue Nov 20 09:58:29 2012] [debug] proxy_util.c(1968): proxy: initialized single connection worker 47 in child 9879 for (my-backend.appserver.com)
[Tue Nov 20 09:58:29 2012] [debug] proxy_util.c(1855): proxy: grabbed scoreboard slot 48 in child 9879 for worker http://my-backend.appserver.com:8080/rest
[Tue Nov 20 09:58:29 2012] [debug] proxy_util.c(1874): proxy: worker http://my-backend.appserver.com:8080/rest already initialized
[Tue Nov 20 09:58:29 2012] [debug] proxy_util.c(1968): proxy: initialized single connection worker 48 in child 9879 for (my-backend.appserver.com)
[Tue Nov 20 09:58:34 2012] [info] Initial (No.1) HTTPS request received for child 5 (server my-front-end.server.com:80)
[Tue Nov 20 09:58:34 2012] [debug] mod_cache.c(131): Adding CACHE_SAVE filter for rest-api/myservice
[Tue Nov 20 09:58:34 2012] [debug] mod_cache.c(138): Adding CACHE_REMOVE_URL filter for rest-api/myservice
[Tue Nov 20 09:58:34 2012] [debug] mod_proxy_http.c(56): proxy: HTTP: canonicalising URL //my-backend.appserver.com:8180:rest-api/myservice
[Tue Nov 20 09:58:34 2012] [debug] proxy_util.c(1489): [client 172.16.9.92] proxy: http: found worker http://my-backend.appserver.com:8180/cfp/6 for http://my-backend.appserver.com:8180:rest-api/myservice?_jsonp=unique_4_&myParam=2
[Tue Nov 20 09:58:34 2012] [debug] mod_proxy.c(988): Running scheme http handler (attempt 0)
[Tue Nov 20 09:58:34 2012] [debug] mod_proxy_http.c(1924): proxy: HTTP: serving URL http://my-backend.appserver.com:8180:rest-api/myservice?_jsonp=unique_4_&myParam=2
[Tue Nov 20 09:58:34 2012] [debug] proxy_util.c(2045): proxy: HTTP: has acquired connection for (my-backend.appserver.com)
[Tue Nov 20 09:58:34 2012] [debug] proxy_util.c(2103): proxy: connecting http://my-backend.appserver.com:8180:rest-api/myservice?_jsonp=unique_4_&myParam=2 to my-backend.appserver.com:8180
[Tue Nov 20 09:58:34 2012] [debug] proxy_util.c(2201): proxy: connected rest-api/myservice?_jsonp=unique_4_&myParam=2 to my-backend.appserver.com:8180
[Tue Nov 20 09:58:34 2012] [debug] proxy_util.c(2356): proxy: HTTP: fam 2 socket created to connect to my-backend.appserver.com
[Tue Nov 20 09:58:34 2012] [debug] proxy_util.c(2468): proxy: HTTP: connection complete to 183.14.15.233:8180 (my-backend.appserver.com)
[Tue Nov 20 09:58:34 2012] [debug] mod_proxy_http.c(1701): proxy: start body send
[Tue Nov 20 09:58:34 2012] [debug] mod_cache.c(528): cache: rest-api/myservice?_jsonp=unique_4_&myParam=2 not cached. Reason: Query string present but no explicit expiration time
[Tue Nov 20 09:58:34 2012] [debug] mod_proxy_http.c(1790): proxy: end body send
[Tue Nov 20 09:58:34 2012] [debug] proxy_util.c(2063): proxy: HTTP: has released connection for (my-backend.appserver.com)

1 Answer 1

0

Found out that the answer was in the version numbers. It turns out that the fix for this behavior first was present in version 2.2.12 - the minor number after the one we use in production ...

From the Changelog for version 2.2.x at Apache, section "Changes with Apache 2.2.12"

  *) mod_cache: When an explicit Expires or Cache-Control header is set, cache
    normally non-cacheable response statuses. PR 46346.
    [Alex Polvi <alex polvi.net>]

The commit can be found here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .