Skip to content

Commit

Permalink
Convert other Mason templates to new headers template
Browse files Browse the repository at this point in the history
27bd738 created a single method in Web.pm, CacheControlExpiresHeaders
to generate HTTP response headers, specifically those related to
caching instructions for browsers. That was applied to Helpers, but
wasn't used for regular RT pages.

Later, 915eb4b sought to fix a regression that resulted in
cache headers not being sent for static files returned via
Plack::Middleware::Static. That fix went to great lengths to
try to re-use functionality from CacheControlExpiresHeaders,
including moving all of the code to GetStaticHeaders. This
probably wasn't really needed since it's reasonable to allow
the special case static handler to send it's own one or two headers.
It also made the code confusing since dynamic pages in Mason
called CacheControlExpiresHeaders, which then called GetStaticHeaders
to get headers for responses that were not static.

This update gets all of the Mason web pages using the same code
for these headers. It leaves the current methods in place to continue
handling static files. That can likely be simplified and cleaned up
in a future commit.
  • Loading branch information
cbrandtbuffalo committed Dec 22, 2023
1 parent 4782390 commit 585bfdb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
6 changes: 2 additions & 4 deletions share/html/Helpers/Autocomplete/autohandler
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
%#
%# END BPS TAGGED BLOCK }}}
<%init>
RT::Interface::Web::CacheControlExpiresHeaders( Time => 2 * 60 );

$m->call_next;
$m->comp('/Elements/HttpResponseHeaders', MaxAgeSeconds => 2 * 60);
$m->call_next;
</%init>

2 changes: 1 addition & 1 deletion share/html/Helpers/RightsInspector/Search
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
use RT::RightsInspector;
my $results = RT::RightsInspector->Search(%ARGS);
$r->content_type('application/json; charset=utf-8');
RT::Interface::Web::CacheControlExpiresHeaders( Time => 'no-cache' );
$m->comp('/Elements/HttpResponseHeaders');
$m->out(JSON($results));
$m->abort;
</%INIT>
5 changes: 2 additions & 3 deletions share/html/Helpers/autohandler
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
%#
%# END BPS TAGGED BLOCK }}}
<%init>
RT::Interface::Web::CacheControlExpiresHeaders( Time => 'no-cache' );

$m->call_next;
$m->comp('/Elements/HttpResponseHeaders');
$m->call_next;
</%init>
4 changes: 2 additions & 2 deletions t/web/helpers-http-cache-headers.t
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ diag "set up expected date headers";
'Expires' => 'Sun, 05 May 2013 15:28:19 GMT',
},
default => {
'Cache-Control' => 'no-cache',
'Expires' => 'Fri, 05 Apr 2013 15:28:19 GMT',
'Cache-Control' => 'no-cache, max-age=0',
'Expires' => 'Fri, 05 Apr 2013 15:27:49 GMT',
},
};

Expand Down

0 comments on commit 585bfdb

Please sign in to comment.