George S. Baugh hace 4 meses
padre
commit
fb470e6813
Se han modificado 2 ficheros con 5 adiciones y 3 borrados
  1. 3 3
      lib/TCMS.pm
  2. 2 0
      lib/Trog/Renderer/Base.pm

+ 3 - 3
lib/TCMS.pm

@@ -75,7 +75,7 @@ sub _app {
 
     # Build the routing table
     state ($conf, $data, %aliases);
-    
+
     $conf  //= Trog::Config::get();
     $data  //= Trog::Data->new($conf);
     my %routes = %{_routes($data)};
@@ -338,9 +338,9 @@ sub _app {
         my $pport = defined $query->{port} ? ":$query->{port}" : "";
         INFO("$env->{REQUEST_METHOD} $output->[0] $fullpath");
 
-        # Append server-timing headers
+        # Append server-timing headers if they aren't present
         my $tot = tv_interval($start) * 1000;
-        push( @{ $output->[1] }, 'Server-Timing' => "app;dur=$tot" );
+        push( @{ $output->[1] }, 'Server-Timing' => "app;dur=$tot" ) unless List::Util::any { $_ eq 'Server-Timing' } @{ $output->[1] };
         return $output;
     }
 }

+ 2 - 0
lib/Trog/Renderer/Base.pm

@@ -12,6 +12,7 @@ use IO::Compress::Gzip;
 use Text::Xslate;
 use Trog::Themes;
 use Trog::Config;
+use Time::HiRes qw{tv_interval};
 
 =head1 Trog::Renderer::Base
 
@@ -79,6 +80,7 @@ sub headers ( $options, $body ) {
         'Cache-Control'          => $query->{cachecontrol} // $Trog::Vars::cache_control{revalidate},
         'X-Content-Type-Options' => 'nosniff',
         'Vary'                   => 'Accept-Encoding',
+        'Server-Timing'          => "render;dur=".(tv_interval($query->{start}) * 1000),
         %$uh,
     );