Re: kernel.org mirroring (Re: [GIT PULL] MMC update)
- From
- Jeff Garzik <jeff@garzik.org>
- Date
- Dec 10, 2006, 13:45 UTC
- Message-ID
- <457C0F8F.7030504@garzik.org>
- In-Reply-To
- <200612101402.51363.jnareb@gmail.com>
Jakub Narebski wrote:
Show 8 quoted lines
> Jeff Garzik wrote: >> Jakub Narebski wrote: >>> P.S. Any hints to how to do this with CGI Perl module? >> It's impossible, Apache doesn't supply e-tag info to CGI programs. (it >> does supply HTTP_CACHE_CONTROL though apparently) > > By ETag info you mean access to HTTP headers sent by browser > If-Modified-Since:, If-Match:, If-None-Match: do you?
You can use this attached shell script as a CGI script, to see precisely what information Apache gives you. You can even experiment with passing back headers other than Content-type (such as E-tag), to see what sort of results are produced. The script currently passes back both E-Tag and Last-Modified of a sample file; modify or delete those lines to suit your experiments.
Show 5 quoted lines
> It's a pity that CGI interface doesn't cover that...
>
>> You could probably do it via mod_perl.
>
> So the cache verification should be wrapped in if ($ENV{MOD_PERL}) ?Sorry, I was /assuming/ mod_perl would make this available. The HTTP header info is available to all Apache modules, but I confess I have no idea how mod_perl passes that info to scripts.
Also, an interesting thing while I was testing the attached shell script: even though repeated hits to the script generate a proper 304 response to the browse, the CGI script and its output run to completion. So, it didn't save work on the CGI side; the savings was solely in not transmitting the document from server to client. The server still went through the work of generating the document (by running the CGI), as one would expect.
Jeff
#!/bin/sh
FN=/tmp/foo
if [ ! -f "$FN" ] then echo "blah blah blah" > "$FN" fi
HASH=`md5sum "$FN"`
echo "Content-type: text/plain" echo "E-tag: $HASH" echo Last-Modified: `date -r /tmp/foo '+%a, %d %b %Y %T %Z'` echo ""
# don't pollute server environment output with our local additions unset FN unset HASH
set