Repository: incubator-trafficcontrol Updated Branches: refs/heads/master 0bd8d4faf -> 1af5663d2
[TC-203] Make /public static files cacheable Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/a9038eb9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/a9038eb9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/a9038eb9 Branch: refs/heads/master Commit: a9038eb990dd90feae1ab3630417428a611393bf Parents: 0bd8d4f Author: Jan van Doorn <jan_vando...@cable.comcast.com> Authored: Tue Mar 21 09:54:34 2017 -0600 Committer: Jan van Doorn <jan_vando...@cable.comcast.com> Committed: Tue Mar 21 09:54:34 2017 -0600 ---------------------------------------------------------------------- traffic_ops/app/lib/TrafficOps.pm | 9 +++++++++ 1 file changed, 9 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a9038eb9/traffic_ops/app/lib/TrafficOps.pm ---------------------------------------------------------------------- diff --git a/traffic_ops/app/lib/TrafficOps.pm b/traffic_ops/app/lib/TrafficOps.pm index 2c5a1a0..b2aeca2 100644 --- a/traffic_ops/app/lib/TrafficOps.pm +++ b/traffic_ops/app/lib/TrafficOps.pm @@ -110,6 +110,15 @@ sub startup { my $static = Mojolicious::Static->new; push @{ $static->paths }, 'public'; + # Make sure static files are cached + $self->hook( + after_static => sub { + my $self = shift; + $self->res->headers->cache_control('max-age=3600, must-revalidate') + if $self->res->code; + } + ); + if ( $mode ne 'test' ) { $access_control_allow_origin = $config->{'cors'}{'access_control_allow_origin'}; if ( defined($access_control_allow_origin) ) {