Added expires header
authorJamie Cameron <jcameron@webmin.com>
Wed, 21 Nov 2007 20:19:02 +0000 (20:19 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 21 Nov 2007 20:19:02 +0000 (20:19 +0000)
CHANGELOG
miniserv.pl

index 83eec8d..3165d4c 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -79,3 +79,4 @@ On Linux systems, sped up the function for finding processes so that it no longe
 When read_file_lines is used to read a file, the Unix or Windows newlines will be preserved when it is written out.
 ---- Changes since 1.380 ----
 Added a search box to the left frame of the blue theme, for finding modules, config options, help pages and text.
+All images, CSS and other static content served by Webmin has an HTTP Expires for 1 week in the future, to improve cachability.
index 3d0d807..ea34689 100755 (executable)
@@ -1898,10 +1898,11 @@ if (-d _) {
 if (-d _) {
        # This is definately a directory.. list it
        print DEBUG "handle_request: listing directory\n";
-       &write_data("HTTP/1.0 $ok_code $ok_message\r\n");
-       &write_data("Date: $datestr\r\n");
-       &write_data("Server: $config{server}\r\n");
-       &write_data("Content-type: text/html\r\n");
+       local $resp = "HTTP/1.0 $ok_code $ok_message\r\n".
+                     "Date: $datestr\r\n".
+                     "Server: $config{server}\r\n".
+                     "Content-type: text/html\r\n";
+       &write_data($resp);
        &write_keep_alive(0);
        &write_data("\r\n");
        &reset_byte_count();
@@ -2217,12 +2218,14 @@ else {
        print DEBUG "handle_request: outputting file\n";
        open(FILE, $full) || &http_error(404, "Failed to open file");
        binmode(FILE);
-       &write_data("HTTP/1.0 $ok_code $ok_message\r\n");
-       &write_data("Date: $datestr\r\n");
-       &write_data("Server: $config{server}\r\n");
-       &write_data("Content-type: ".&get_type($full)."\r\n");
-       &write_data("Content-length: $stfull[7]\r\n");
-       &write_data("Last-Modified: ".&http_date($stfull[9])."\r\n");
+       local $resp = "HTTP/1.0 $ok_code $ok_message\r\n".
+                     "Date: $datestr\r\n".
+                     "Server: $config{server}\r\n".
+                     "Content-type: ".&get_type($full)."\r\n".
+                     "Content-length: $stfull[7]\r\n".
+                     "Last-Modified: ".&http_date($stfull[9])."\r\n".
+                     "Expires: ".&http_date(time()+$config{'expires'})."\r\n";
+       &write_data($resp);
        $rv = &write_keep_alive();
        &write_data("\r\n");
        &reset_byte_count();
@@ -3838,6 +3841,7 @@ my %vital = ("port", 80,
          "sidname", "sid",
          "unauth", "^/unauthenticated/ ^[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\$",
          "max_post", 10000,
+         "expires", 7*24*60*60,
         );
 foreach my $v (keys %vital) {
        if (!$config{$v}) {