Hi,

I'm trying to make a web application (Apache Cocoon) as much proxy-friendly as possible, with the idea of being able to serve costly and almost static requests straight from a reverse proxy instead than directly from the application.

I've read RFC 2616, some tutorials and the Squid FAQs, but still there is something that doesn't work, either in my application or (even worse) in my understanding of the mechanics of caching.

Basically, from my application I'm setting a couple of proxy-friendly headers (expires and cache-control) in order to instruct the proxy to cache the result. From what I see by sniffing the traffic, the headers are correct. The squid log files, also, label the content as FRESH, so it seems that everything is working as expected.

Unfortunately this is not the case. I'm still getting hits on my backend server on a 1:1 ratio (one hit on the reverse proxy means one hit on my backend server), together with TCP_MISSes on the Squid side which means that my server is not being offloaded at all (agreed, except for network bottlenecks).

What am I missing? I'm enclosing a snippet of the network conversation, as well as a relevant (well, to me at least, feel free to ask for more) excerpt from the log files:

Client is sending:


GET /samples/hello-world/hello.html HTTP/1.0
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1?
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate,compress;q=0.9
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Via: 1.1 linux.local:3128 (squid/2.5.STABLE1)
X-Forwarded-For: 127.0.0.1
Host: localhost
Cache-Control: max-age=0
Connection: keep-alive

The backend server consistently answers with:

HTTP/1.1 200 OK
Date: Mon, 10 Feb 2003 14:52:37 GMT
Server: Jetty/4.2.7 (Linux/2.4.19-4GB i386 java/1.4.1_01)
X-Cocoon-Version: 2.1-dev
Content-Type: text/html
Cache-Control: max-age=86400, public
Expires: Tue, 11 Feb 2003 14:52:38 GMT
Content-Length: 996
Connection: keep-alive

FYI: now is Mon Feb 10 14:54:11 GMT 2003 here, expires was set to one day, so everything seems right. Squid log (squid -k) says

2003/02/10 15:52:37| clientCacheHit: http://localhost:8890/samples/hello-world/hello.html, 1286 bytes
2003/02/10 15:52:37| 0x83ca2cc lookup for 49
2003/02/10 15:52:37| refreshCheck: 'http://localhost:8890/samples/hello-world/hello.html'
2003/02/10 15:52:37| FRESH: expires 1044975130 >= check_time 1044888757
2003/02/10 15:52:37| Staleness = -1
2003/02/10 15:52:37| refreshCheck: Matched '. 0 20% 259200'
2003/02/10 15:52:37| refreshCheck: age = 27
2003/02/10 15:52:37| check_time: Mon, 10 Feb 2003 14:52:37 GMT

Which suggests to me that once again everything is fine, yet:


1044888758.143 435 127.0.0.1 TCP_MISS/200 1318 GET http://localhost:8890/samples/hello-world/hello.html - DIRECT/127.0.0.1 text/html

And an access occurs on my backend server... gosh, why? :-/

I feel a bit stuck, and I have this strange feeling of having overlooked something really important, so please forgive my ignorance. With my dumbass hat handy, I wait for your help: fire at will.

TIA,

--
Gianugo Rabellino
Pro-netics s.r.l.
http://www.pro-netics.com

Reply via email to