Skip to content

Commit f303cdc

Browse files
committed
Remove the STATIC_EXPIRES option.
The option is set up to set an expiration for static assets served from the `webwork2_files` route. However, there is no such route anymore for the renderer, and so the option currently does nothing. This could be adapted to work for the other files in public, but there is not point in that. The static assets used in production are either local assets that are minimized and served with a hash in the file name, or are third party assets and a version parameter is appended as a query parameter. As such, when files change the browser will get the new versions.
1 parent d5a1000 commit f303cdc

File tree

2 files changed

+0
-30
lines changed

2 files changed

+0
-30
lines changed

lib/RenderApp.pm

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -85,35 +85,6 @@ sub startup {
8585
$self->helper(logAttempt => sub { shift; $resultsLog->info(@_); });
8686
}
8787

88-
# Add Cache-Control and Expires headers to static content from webwork2_files
89-
if (my $STATIC_EXPIRES = $self->config('STATIC_EXPIRES')) {
90-
$STATIC_EXPIRES = int($STATIC_EXPIRES);
91-
my $cache_control_setting = "max-age=$STATIC_EXPIRES";
92-
my $no_cache_setting = 'max-age=1, no-cache';
93-
$self->hook(
94-
after_dispatch => sub {
95-
my $c = shift;
96-
97-
# Only process if file requested is under webwork2_files
98-
return unless ($c->req->url->path =~ '^/webwork2_files/');
99-
100-
if ($c->req->url->path =~ '/tmp/renderer') {
101-
# Treat problem generated files as already expired.
102-
# They should not be cached.
103-
$c->res->headers->cache_control($no_cache_setting);
104-
$c->res->headers->header(
105-
Expires => Mojo::Date->new(time - 86400) # expired 24 hours ago
106-
);
107-
} else {
108-
# Standard "static" files.
109-
# They can be cached
110-
$c->res->headers->cache_control($cache_control_setting);
111-
$c->res->headers->header(Expires => Mojo::Date->new(time + $STATIC_EXPIRES));
112-
}
113-
}
114-
);
115-
}
116-
11788
# Models
11889
$self->helper(newProblem => sub { shift; RenderApp::Model::Problem->new(@_) });
11990

render_app.conf.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
webworkJWTsecret => 'private',
77
SITE_HOST => 'http://localhost:3000',
88
CORS_ORIGIN => '*',
9-
STATIC_EXPIRES => 86400,
109
STRICT_JWT => 0,
1110
FULL_APP_INSECURE => 0,
1211
INTERACTION_LOG => 0,

0 commit comments

Comments
 (0)