- -r $source or Abort("Requested file not found", '404 source not found');
- my $size = (stat $source)->[7];
+ -r $path or Abort("Requested file not found", '404 source not found');
+ my $size = (stat $path)->[7];
+
+ my $cachefile = "source/$source.html";
+ if (-e $cachefile and (stat $cachefile)->[9] >= (stat $path)->[9]) {
+ say '<pre>';
+ print ReadFile($cachefile);
+ say '</pre>';
+ exit;
+ }
+ -e or mkdir for $cachefile =~ s{[^/]+\z}{}r; # dirname
+ open my $cache, '>', $cachefile
+ or Alert("Could not save cache", "Opening $cachefile failed: $!");;