gitweb: blobs defined by non-textual hash ids can be cached
Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jakub Narebski committed
Aug 26, 2006 at 19:14 UTC
f2e73302994b6072e556df1af998c0afd643e833
1 file changed
+17
-3
gitweb/gitweb.perl
+17
-3
@@ -2363,6 +2363,12 @@ sub git_heads {
2363
}
2364
2365
sub git_blob_plain {
2366
+ # blobs defined by non-textual hash id's can be cached
2367
+ my $expires;
2368
+ if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2369
+ $expires = "+1d";
2370
+ }
2371
+
2372
if (!defined $hash) {
2373
if (defined $file_name) {
2374
my $base = $hash_base || git_get_head_hash($project);
@@ -2386,8 +2392,10 @@ sub git_blob_plain {
2392
$save_as .= '.txt';
2393
}
2394
2389
- print $cgi->header(-type => "$type",
2390
- -content_disposition => "inline; filename=\"$save_as\"");
2395
+ print $cgi->header(
2396
+ -type => "$type",
2397
+ -expires=>$expires,
2398
+ -content_disposition => "inline; filename=\"$save_as\"");
2399
undef $/;
2400
binmode STDOUT, ':raw';
2401
print <$fd>;
@@ -2397,6 +2405,12 @@ sub git_blob_plain {
2405
}
2406
2407
sub git_blob {
2408
+ # blobs defined by non-textual hash id's can be cached
2409
+ my $expires;
2410
+ if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2411
+ $expires = "+1d";
2412
+ }
2413
+
2414
if (!defined $hash) {
2415
if (defined $file_name) {
2416
my $base = $hash_base || git_get_head_hash($project);
@@ -2414,7 +2428,7 @@ sub git_blob {
2428
close $fd;
2429
return git_blob_plain($mimetype);
2430
}
2417
- git_header_html();
2431
+ git_header_html(undef, $expires);
2432
my $formats_nav = '';
2433
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
2434
if (defined $file_name) {