git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
To: Jakub Narebski <jnareb@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] gitweb: check if-modified-since for feeds
Date: Mon, 26 Jan 2009 12:25:18 +0100	[thread overview]
Message-ID: <cb7bb73a0901260325j74f07f3doee3aad9b0300ee88@mail.gmail.com> (raw)
In-Reply-To: <200901260318.05301.jnareb@gmail.com>

On Mon, Jan 26, 2009 at 3:18 AM, Jakub Narebski <jnareb@gmail.com> wrote:
> Should be "[PATCH 2/2]" or similar, just in case.

Yeah, but I was just hacking up ideas as they came. I'm planning a
resend of the whole series, properly numbered and all.

> On Sun, 25 Jun 2009, Giuseppe Bilotta wrote:
>
>> Offering Last-modified header
>
> And skipping generating the body if client uses 'HEAD' request to
> get only Last-Modified header.
>
>>                              for feeds is only half the work: we should
>> also check that same date against If-modified-since, and bail out early
>> with 304 Not Modified.
>
> Lacks signoff.

Oh yeah.

>> -             %latest_date   = parse_date($latest_commit{'committer_epoch'});
>> +             my $latest_epoch = $latest_commit{'committer_epoch'};
>> +             %latest_date   = parse_date($latest_epoch);
>> +             my $if_modified = $cgi->http('IF_MODIFIED_SINCE');
>> +             if (defined $if_modified) {
>> +                     my $since;
>> +                     if (eval { require HTTP::Date; 1; }) {
>> +                             $since = HTTP::Date::str2time($if_modified);
>> +                     } elsif (eval { require Time::ParseDate; 1; }) {
>> +                             $since = Time::ParseDate::parsedate($if_modified, GMT => 1);
>> +                     }
>
> I'd really like to fallback on hand-parsing, as we have to parse date
> in well defined HTTP-date format (RFC-1123, update to RFC-822), which
> I think is what we send in Last-Modified header (or is it RFC-2822?).
>
> But that might be too much work. I like the checking for modules,
> and the fallback cascade, but could you explain why in this order?

Of course, if we have our own parsing code, we don't need the other
modules. I'm way too lazy to write the parsing code myself, although a
copypaste from existing GPL code would do it.

(BTW, I asked on #perl and they think gitweb non-reliance on CPAN
makes for some very horrible code. Of course, IMO the real problem is
that perl's stdlib is way too limited, but that is likely to causes a
language war so I refrained from discussing the thing.)

The order is almost casual, but I suspect that HTTP::Date, from
libwww-perl, is more likely to be available on a webserver than the
other.

>> +                     if (defined $since && $latest_epoch <= $since) {
>> +                             print $cgi->header(
>> +                                     -type => $content_type,
>> +                                     -charset => 'utf-8',
>> +                                     -last_modified => $latest_date{'rfc2822'},
>> +                                     -status => 304);
>
> I think we spell HTTP status messages in full (even if it is hidden
> in die_error subroutine), i.e.
>
> +                                       -status => '304 Not Modified');

Can do that.

> P.S. It would be nice to have this mechanism (responding to
> cache-control headers such as If-Modified-Since) for all of gitweb,
> but I guess it is most critical for feeds, which are _polled_.

I thought so too, but then again I couldn't see where last-modified
was used. (Its usage could be added, of course.)

-- 
Giuseppe "Oblomov" Bilotta

  reply	other threads:[~2009-01-26 11:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-23  4:48 [PATCH 0/4] gitweb feed metadata tuneups Giuseppe Bilotta
2009-01-23  4:48 ` [PATCH 1/4] gitweb: channel image in rss feed Giuseppe Bilotta
2009-01-23  4:48   ` [PATCH 2/4] gitweb: feed generator metadata Giuseppe Bilotta
2009-01-23  4:48     ` [PATCH 3/4] gitweb: rss feed managingEditor Giuseppe Bilotta
2009-01-23  4:48       ` [PATCH 4/4] gitweb: rss channel date Giuseppe Bilotta
2009-01-25 22:42         ` [PATCH] gitweb: last-modified time should be commiter, not author Giuseppe Bilotta
2009-01-25 22:42           ` [PATCH] gitweb: check if-modified-since for feeds Giuseppe Bilotta
2009-01-26  2:18             ` Jakub Narebski
2009-01-26 11:25               ` Giuseppe Bilotta [this message]
2009-02-02 22:28                 ` Jakub Narebski
2009-01-26  1:54           ` [PATCH] gitweb: last-modified time should be commiter, not author Jakub Narebski
2009-01-26 11:43             ` Giuseppe Bilotta
2009-01-24 16:02 ` [PATCH 0/4] gitweb feed metadata tuneups Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb7bb73a0901260325j74f07f3doee3aad9b0300ee88@mail.gmail.com \
    --to=giuseppe.bilotta@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).