diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-09-18 16:24:06 -0700 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-09-18 16:24:06 -0700 |
commit | 46317c3190e95cca62cd5d932bd6bc4b45e75d23 (patch) | |
tree | cf8b01dfc39fb3cc8bd6c43349b97e58f5947052 /Bugzilla/Template.pm | |
parent | 7df0160f6aaf3adcb3e6ddca0fc172c5ea89eb8c (diff) | |
download | bugs-46317c3190e95cca62cd5d932bd6bc4b45e75d23.tar bugs-46317c3190e95cca62cd5d932bd6bc4b45e75d23.tar.gz bugs-46317c3190e95cca62cd5d932bd6bc4b45e75d23.tar.bz2 bugs-46317c3190e95cca62cd5d932bd6bc4b45e75d23.tar.xz bugs-46317c3190e95cca62cd5d932bd6bc4b45e75d23.zip |
Bug 586244: Make mod_headers and mod_expires optional
r=glob, a=mkanat
Diffstat (limited to 'Bugzilla/Template.pm')
-rw-r--r-- | Bugzilla/Template.pm | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 13ba22776..0997415b2 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -399,10 +399,17 @@ sub multiline_sprintf { sub _mtime { return (stat($_[0]))[9] } sub mtime_filter { - my ($file_url) = @_; - my $cgi_path = bz_locations()->{'cgi_path'}; - my $file_path = "$cgi_path/$file_url"; - return "$file_url?" . _mtime($file_path); + my ($file_url, $mtime) = @_; + # This environment var is set in the .htaccess if we have mod_headers + # and mod_expires installed, to make sure that JS and CSS with "?" + # after them will still be cached by clients. + return $file_url if !$ENV{BZ_CACHE_CONTROL}; + if (!$mtime) { + my $cgi_path = bz_locations()->{'cgi_path'}; + my $file_path = "$cgi_path/$file_url"; + $mtime = _mtime($file_path); + } + return "$file_url?$mtime"; } # Set up the skin CSS cascade: @@ -453,8 +460,7 @@ sub css_files { sub _css_link_set { my ($file_name) = @_; - my $standard_mtime = _mtime($file_name); - my %set = (standard => $file_name . "?$standard_mtime"); + my %set = (standard => mtime_filter($file_name)); # We use (^|/) to allow Extensions to use the skins system if they # want. @@ -471,7 +477,7 @@ sub _css_link_set { my $skin_file_name = $file_name; $skin_file_name =~ s{(^|/)skins/standard/}{skins/contrib/$option/}; if (my $mtime = _mtime("$cgi_path/$skin_file_name")) { - $skin_urls{$option} = $skin_file_name . "?$mtime"; + $skin_urls{$option} = mtime_filter($skin_file_name, $mtime); } } $set{alternate} = \%skin_urls; @@ -484,7 +490,7 @@ sub _css_link_set { my $custom_file_name = $file_name; $custom_file_name =~ s{(^|/)skins/standard/}{skins/custom/}; if (my $custom_mtime = _mtime("$cgi_path/$custom_file_name")) { - $set{custom} = $custom_file_name . "?$custom_mtime"; + $set{custom} = mtime_filter($custom_file_name, $custom_mtime); } return \%set; |