add Expires: +1d header to commit and commitdiff pages
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Kay Sievers committed
Oct 19, 2005 at 03:18 UTC
11044297b21e0ecabc22c055e43be7bfd3972dff
1 file changed
+15
-3
gitweb.cgi
+15
-3
@@ -208,6 +208,7 @@ if (!defined $action || $action eq "summary") {
208
209
sub git_header_html {
210
my $status = shift || "200 OK";
211
+ my $expires = shift;
212
213
my $title = "git";
214
if (defined $project) {
@@ -216,7 +217,7 @@ sub git_header_html {
217
$title .= "/$action";
218
}
219
}
219
- print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status);
220
+ print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status, -expires => $expires);
221
print <<EOF;
222
<?xml version="1.0" encoding="utf-8"?>
223
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@@ -1620,7 +1621,13 @@ sub git_commit {
1621
open my $fd, "-|", "$gitbin/git-diff-tree -r -M $root $parent $hash" or die_error(undef, "Open failed.");
1622
@difftree = map { chomp; $_ } <$fd>;
1623
close $fd or die_error(undef, "Reading diff-tree failed.");
1623
- git_header_html();
1624
+
1625
+ # non-textual hash id's can be cached
1626
+ my $expires;
1627
+ if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
1628
+ $expires = "+1d";
1629
+ }
1630
+ git_header_html(undef, $expires);
1631
print "<div class=\"page_nav\">\n" .
1632
$cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1633
" | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .
@@ -1852,7 +1859,12 @@ sub git_commitdiff {
1859
my (@difftree) = map { chomp; $_ } <$fd>;
1860
close $fd or die_error(undef, "Reading diff-tree failed.");
1861
1855
- git_header_html();
1862
+ # non-textual hash id's can be cached
1863
+ my $expires;
1864
+ if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
1865
+ $expires = "+1d";
1866
+ }
1867
+ git_header_html(undef, $expires);
1868
print "<div class=\"page_nav\">\n" .
1869
$cgi->a({-href => "$my_uri?p=$project;a=summary"}, "summary") .
1870
" | " . $cgi->a({-href => "$my_uri?p=$project;a=shortlog;h=$hash"}, "shortlog") .