"Server: $config{server}\r\n".
"Content-type: ".&get_type($full)."\r\n".
"Last-Modified: ".&http_date($stopen[9])."\r\n".
- "Expires: ".&http_date(time()+$config{'expires'})."\r\n";
+ "Expires: ".
+ &http_date(time()+&get_expires_time($simple))."\r\n";
if (!$gzipped && $use_gzip && $acceptenc{'gzip'} &&
&should_gzip_file($full)) {
"maxconns", 50,
"pam", "webmin",
"sidname", "sid",
- "unauth", "^/unauthenticated/ ^/robots.txt\$ ^[A-Za-z0-9\\-/_]+\\.jar\$ ^[A-Za-z0-9\\-/_]+\\.class\$ ^[A-Za-z0-9\\-/_]+\\.gif\$ ^[A-Za-z0-9\\-/_]+\\.conf\$ ^[A-Za-z0-9\\-/_]+\\.ico\$ ^/robots.txt\$",
+ "unauth", "^/unauthenticated/ ^/robots.txt\$ ^[A-Za-z0-9\\-/_]+\\.jar\$ ^[A-Za-z0-9\\-/_]+\\.class\$ ^[A-Za-z0-9\\-/_]+\\.gif\$ ^[A-Za-z0-9\\-/_]+\\.png\$ ^[A-Za-z0-9\\-/_]+\\.conf\$ ^[A-Za-z0-9\\-/_]+\\.ico\$ ^/robots.txt\$",
"max_post", 10000,
"expires", 7*24*60*60,
"pam_test_user", "root",
@mobile_agents = split(/\t+/, $config{'mobile_agents'});
@mobile_prefixes = split(/\s+/, $config{'mobile_prefixes'});
+# Expires time list
+@expires_paths = ( );
+foreach my $pe (split(/\t+/, $config{'expires_paths'})) {
+ my ($p, $e) = split(/=/, $pe);
+ if ($p && $e ne '') {
+ push(@expires_paths, [ $p, $e ]);
+ }
+ }
+
# Open debug log
close(DEBUG);
if ($config{'debug'}) {
return $path !~ /\.(gif|png|jpg|jpeg|tif|tiff)$/i;
}
+# get_expires_time(path)
+# Given a URL path, return the client-side expiry time in seconds
+sub get_expires_time
+{
+my ($path) = @_;
+foreach my $pe (@expires_paths) {
+ if ($path =~ /$pe->[0]/i) {
+ return $pe->[1];
+ }
+ }
+return $config{'expires'};
+}
+
---- Changes since 1.550 ----
Added fields to the Index Page Options page to control the display of Webmin and module updates.
Moved settings related to Webmin's built-in webserver to the new Web Server Options page.
+The client-side expiry time for static files served by Webmin can now be configured on the Web Server Options page, and can be customized on a per-file basis.
$miniserv{'expires'} = $in{'expires'};
}
+# Save per-path expires
+for(my $i=0; defined($p = $in{"expirespath_$i"}); $i++) {
+ $t = $in{"expirestime_$i"};
+ next if ($p !~ /\S/);
+ $t =~ /^\d+$/ || &error(&text('web_eexpires2', $i+1));
+ push(@expires_paths, [ $p, $t ]);
+ }
+$miniserv{'expires_paths'} = join("\t", map { $_->[0]."=".$_->[1] }
+ @expires_paths);
+
# Save stack trace option
$gconfig{'error_stack'} = $in{'stack'};
&ui_opt_textbox("expires", $miniserv{'expires'}, 10,
$text{'web_expiresdef'}, $text{'web_expiressecs'}));
+# Additonal expiry times based on path
+my @expires_paths;
+foreach my $pe (split(/\t+/, $miniserv{'expires_paths'})) {
+ my ($p, $e) = split(/=/, $pe);
+ if ($p && $e ne '') {
+ push(@expires_paths, [ $p, $e ]);
+ }
+ }
+push(@expires_paths, [ undef, $miniserv{'expires'} || 86400 ]);
+my $etable = &ui_columns_start([ $text{'web_expirespath'},
+ $text{'web_expirestime'} ]);
+for(my $i=0; $i<@expires_paths; $i++) {
+ $etable .= &ui_columns_row([
+ &ui_textbox("expirespath_$i", $expires_paths[$i]->[0], 40),
+ &ui_textbox("expirestime_$i", $expires_paths[$i]->[1], 10),
+ ]);
+ }
+$etable .= &ui_columns_end();
+print &ui_table_row($text{'web_expirespaths'}, $etable);
+
# Show call stack on error
print &ui_table_row($text{'advanced_stack'},
&ui_yesno_radio("stack", int($gconfig{'error_stack'})));
web_expiresdef=Webmin default (7 days)
web_expiressecs=Time in seconds
web_err=Failed to save web server options
-web_eexpires=Missing or non-numeric client size cache time
+web_eexpires=Missing or non-numeric client side cache time
+web_expirespaths=Client-side cache times based on URL path
+web_expirespath=Path regular expression
+web_expirestime=Cache time in seconds
+web_eexpires2=Missing or non-numeric client side cache time in row $1
__norefs=1