Skip to content

Commit f3f56c2

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 31abf57 commit f3f56c2

File tree

2 files changed

+0
-30
lines changed

2 files changed

+0
-30
lines changed

lib/Renderer.pm

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

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

renderer.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)