ProxyPass, caching and If-Modified-Since

ProxyPass, caching and If-Modified-Since

am 23.05.2002 16:56:40 von Daniel Barlow

I'm looking at proxy_http.c in 1.3.24, and wondering what would happen
if it added If-Modified-Since headers to any requests it does for
which it has a cached response already, using the Last-Modified time
of the cached response.

Why do I want to? I have mod_proxy configured with ProxyPass and
ProxyPassReverse to front an application server, some of the responses
from which are quite computation-intensive and thus slow. The
application server correctly sets Last-Modified and handles
conditional GETs, which saves some time when the same client requests
the page twice, but doesn't help if two different clients request the
same page.

Does this make sense? I'm wondering whether (a) it breaks HTTP, (b)
it breaks some well-known client/origin server, (c) nobody else is
weird enough to need it, or (d) it's dumb for some other reason? I
have a passing familiarity with HTTP, but I'm not exactly a domain
expert.


-dan

--

http://ww.telent.net/cliki/ - Link farm for free CL-on-Unix resources

Re: ProxyPass, caching and If-Modified-Since

am 24.05.2002 09:59:16 von Graham Leggett

This is a cryptographically signed message in MIME format.

--------------msFF5B436179C2B9F218011DE1
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Daniel Barlow wrote:

> I'm looking at proxy_http.c in 1.3.24, and wondering what would happen
> if it added If-Modified-Since headers to any requests it does for
> which it has a cached response already, using the Last-Modified time
> of the cached response.
>
> Why do I want to? I have mod_proxy configured with ProxyPass and
> ProxyPassReverse to front an application server, some of the responses
> from which are quite computation-intensive and thus slow. The
> application server correctly sets Last-Modified and handles
> conditional GETs, which saves some time when the same client requests
> the page twice, but doesn't help if two different clients request the
> same page.

It should make no difference whether the two requests come from the same
or different clients, as each request is independant within itself. In
theory any HTTP compliant proxy should do what you want it to do
already.

Keep in mind though that a far better way of solving your problem is to
make sure that your application server generates ETag headers in the
responses. An ETag is a unique identifier attached to an object which
can be used in an If-None-Match conditional request. See RFC2616 and
look up the ETag header, the If-None-Match header for a full explanation
of how this mechanism works in HTTP/1.1.

In the simplest solution (as I understand it), you could get away with
adding a random ETag to each response (implying that every response is
different from the last one) and then specifying "Cache-Control:
max-age=3600". This means "dear cache, I would like you to cache this
response and consider it fresh for 3600 seconds, and only after that
contact me again to check if the page is up to date, unless any other
Cache-Control headers dictate you should do otherwise".

In your application however, you support conditional gets. Thus you
should return the same Etag with each request with the same data. ie, if
you change the data in any way, change the ETag attached to the request.
(Hopefully I haven;t confused you more, full details are in RFC2616).

Regards,
Graham
--
-----------------------------------------
minfrin@sharp.fm "There's a moon
over Bourbon Street
tonight..."
--------------msFF5B436179C2B9F218011DE1
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

MIIIAAYJKoZIhvcNAQcCoIIH8TCCB+0CAQExCzAJBgUrDgMCGgUAMAsGCSqG SIb3DQEHAaCC
Bf4wggLNMIICNqADAgECAgMHh88wDQYJKoZIhvcNAQEEBQAwgZIxCzAJBgNV BAYTAlpBMRUw
EwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEPMA0G A1UEChMGVGhh
d3RlMR0wGwYDVQQLExRDZXJ0aWZpY2F0ZSBTZXJ2aWNlczEoMCYGA1UEAxMf UGVyc29uYWwg
RnJlZW1haWwgUlNBIDIwMDAuOC4zMDAeFw0wMjA1MjMxMzQzMDVaFw0wMzA1 MjMxMzQzMDVa
MIGAMRAwDgYDVQQEEwdMZWdnZXR0MQ8wDQYDVQQqEwZHcmFoYW0xFzAVBgNV BAMTDkdyYWhh
bSBMZWdnZXR0MR8wHQYJKoZIhvcNAQkBFhBtaW5mcmluQHNoYXJwLmZtMSEw HwYJKoZIhvcN
AQkBFhJtaW5mcmluQGFwYWNoZS5vcmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0A MIGJAoGBAMu6
SGJLfqv2lRy+TAhi2K5KhF70x9RHqyptGfCBVgwOdRKcAfpmo8R9aqEjc829 cKBwrkiA5QHW
mTK9vXMtQ1kAwsK0woyFLN2dpvCqhxgUTYm7rKFJjMrISzuXnJT5y1R7zMgV bznU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