From: Kay Sievers Date: Wed, 19 Oct 2005 01:18:45 +0000 (+0200) Subject: add Expires: +1d header to commit and commitdiff pages X-Git-Tag: v1.4.0~1^2~47 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=11044297b21e0ecabc22c055e43be7bfd3972dff;p=git.git add Expires: +1d header to commit and commitdiff pages Signed-off-by: Kay Sievers --- diff --git a/gitweb.cgi b/gitweb.cgi index a11f2974..873b7ce1 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -208,6 +208,7 @@ if (!defined $action || $action eq "summary") { sub git_header_html { my $status = shift || "200 OK"; + my $expires = shift; my $title = "git"; if (defined $project) { @@ -216,7 +217,7 @@ sub git_header_html { $title .= "/$action"; } } - print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status); + print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status, -expires => $expires); print < @@ -1620,7 +1621,13 @@ sub git_commit { open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $parent $hash" or die_error(undef, "Open failed."); @difftree = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); - git_header_html(); + + # non-textual hash id's can be cached + my $expires; + if ($hash =~ m/^[0-9a-fA-F]{40}$/) { + $expires = "+1d"; + } + git_header_html(undef, $expires); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") . @@ -1852,7 +1859,12 @@ sub git_commitdiff { my (@difftree) = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading diff-tree failed."); - git_header_html(); + # non-textual hash id's can be cached + my $expires; + if ($hash =~ m/^[0-9a-fA-F]{40}$/) { + $expires = "+1d"; + } + git_header_html(undef, $expires); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .