]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Set some default caching headers
authorDylan Hardison <dylan@hardison.net>
Sat, 16 May 2020 02:58:38 +0000 (22:58 -0400)
committerDylan Hardison <dylan@hardison.net>
Sat, 16 May 2020 03:00:00 +0000 (23:00 -0400)
Bugzilla.pm
Bugzilla/App/CGI.pm

index e6a1092a064a9b8bf3aaa9193f55091634ab5fad..eb739920ffa82e7518b573aaa94282ddfdfb49a6 100644 (file)
@@ -158,7 +158,8 @@ sub input_params {
 }
 
 sub localconfig {
-  return $_[0]->process_cache->{localconfig} ||= Bugzilla::Localconfig->new(read_localconfig());
+  return $_[0]->process_cache->{localconfig}
+    ||= Bugzilla::Localconfig->new(read_localconfig());
 }
 
 
@@ -327,7 +328,7 @@ sub login {
       }
     }
     else {
-      my $dbh = Bugzilla->dbh_main;
+      my $dbh  = Bugzilla->dbh_main;
       my $date = $dbh->sql_date_math('NOW()', '+', '?', 'DAY');
       my ($mfa_required_date)
         = $dbh->selectrow_array("SELECT $date", undef, $grace_period);
@@ -389,6 +390,12 @@ sub login {
 
   # If Mojo native app is requesting login, we need to possibly redirect
   my $C = $Bugzilla::App::CGI::C;
+  if ($class->user->id) {
+    $C->res->headers->cache_control('private, max-age=60');
+  }
+  else {
+    $C->res->headers->cache_control('public, max-age=300');
+  }
   my $session = $C->session;
   if (!$on_token_page && $session->{override_login_target}) {
     my $override_login_target = delete $session->{override_login_target};
@@ -643,7 +650,7 @@ sub fields {
   my $fields = $cache->{fields};
   my %requested;
   if (my $types = delete $criteria->{type}) {
-    $types = ref($types) ? $types : [$types];
+    $types     = ref($types) ? $types : [$types];
     %requested = map { %{$fields->{by_type}->{$_} || {}} } @$types;
   }
   else {
@@ -670,7 +677,7 @@ sub fields {
 
 sub active_custom_fields {
   my (undef, $params, $wants) = @_;
-  my $cache_id = 'active_custom_fields';
+  my $cache_id  = 'active_custom_fields';
   my $can_cache = !exists $params->{bug_id} && !$wants;
   if ($can_cache && $params) {
     $cache_id .= ($params->{product} ? '_p' . $params->{product}->id : '')
@@ -724,7 +731,7 @@ sub audit {
 sub clear_request_cache {
   my (undef, %option) = @_;
   my $request_cache = request_cache();
-  my @except = $option{except} ? @{$option{except}} : ();
+  my @except        = $option{except} ? @{$option{except}} : ();
 
   %{$request_cache} = map { $_ => $request_cache->{$_} } @except;
 }
@@ -820,7 +827,7 @@ sub _cleanup {
   my $main   = Bugzilla->request_cache->{dbh_main};
   my $shadow = Bugzilla->request_cache->{dbh_shadow};
   foreach my $dbh ($main, $shadow) {
-    next if !$dbh;
+    next                            if !$dbh;
     $dbh->bz_rollback_transaction() if $dbh->bz_in_transaction;
   }
   clear_request_cache();
index 29b2842162351a348fc0dd7bf7ac2ef3b19b954a..d212276a90910f5258667f964822858cf9ece67a 100644 (file)
@@ -9,6 +9,7 @@ package Bugzilla::App::CGI;
 use Mojo::Base 'Mojolicious::Controller';
 
 use CGI::Compile;
+use Bugzilla::Logging;
 use Try::Tiny;
 use Sys::Hostname;
 use Sub::Quote 2.005000;