Mailing List Archive

ETAG and Vary with reverse proxy and xsendfile
Dear Experts,

I have a server which functions as follows:

1. Incoming requests are sent to a reverse proxy which
inspects the request headers and returns a response to
Apache which contains an X-SendFile header containing the
path of the file to serve.

2. mod_xsendfile (see https://github.com/nmaier/mod_xsendfile)
sends the specified file to the client.

This all works fine, except for ETAGs, Vary, and
If-None-Match requests.

What do I have to do to make this work?

Currently, all responses seem to have ETAG: "0". I'd like
the ETAG to be based in the normal way on the attributes
of the file that mod_xsendfile actually sends.

Where is the ETAG added? Is it upstream or downstream
of wherever mod_xsendfile sits? Is this something that
mod_xsendfile needs to do itself? Its only mention of
ETAG is its XSendFileIgnoreEtag option, which tells it
to "ignore all ETag headers the original output handler
may have set". Changing it doesn't seem to affect the
behaviour I am seeing.

I guess that I need a "Header add" directive to add a
Vary: header to the response, indicating which headers
my proxy looks at. Or maybe the proxy should just output
a Vary: header itself.

Finally, what do I need to do to support If-None-Match
requests? At what point is that checked? I need for my
proxy to run and determine which file will be served,
and then for the ETAG for that file to be determined,
and then finally for that to be compared with the tag
in the If-None-Match header. Is that possible, or does
Apache need to do the If-None-Match check earlier on?

Any help would be much appreciated. I know mod_xsendfile
is not an official Apache thing but I'm sure many readers
will be a little familiar with it, and it is only one
700-line .c file.


Thanks, Phil.





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: ETAG and Vary with reverse proxy and xsendfile [ In reply to ]
Yesterday I asked:
> 2. mod_xsendfile (see https://github.com/nmaier/mod_xsendfile)
> sends the specified file to the client.

> Currently, all responses seem to have ETAG: "0". I'd like
> the ETAG to be based in the normal way on the attributes
> of the file that mod_xsendfile actually sends.


I believe I've found a bug in mod_xsendfile that explains this.

This module doesn't seem to have had much attention from its author
for a number of years, yet it does provide a useful feature (which
some other servers have built-in). Has Apache ever considered
adopting this module, or otherwise adding this functionality?

(I'm still unsure if sending valid ETags is sufficient to make
If-None-Match work, i.e. whether the checking for that is up or
downstream of where mod_xsendfile sits - any comments anyone?)


Regard, Phil.





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Re: ETAG and Vary with reverse proxy and xsendfile [ In reply to ]
> (I'm still unsure if sending valid ETags is sufficient to make
> If-None-Match work, i.e. whether the checking for that is up or
> downstream of where mod_xsendfile sits - any comments anyone?)

Yes, this is the part that that's relevant:
https://github.com/nmaier/mod_xsendfile/blob/master/mod_xsendfile.c#L558
If there was a valid ETAG at this point, it would trigger the
conditional request handling. It looks like preceding this line the
module is trying to get the core to set the same ETAG it would have
set if serving the static file directly.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org