Skip to content

Remove the STATIC_EXPIRES option. #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions lib/RenderApp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,6 @@ sub startup {
$self->helper(logAttempt => sub { shift; $resultsLog->info(@_); });
}

# Add Cache-Control and Expires headers to static content from webwork2_files
if (my $STATIC_EXPIRES = $self->config('STATIC_EXPIRES')) {
$STATIC_EXPIRES = int($STATIC_EXPIRES);
my $cache_control_setting = "max-age=$STATIC_EXPIRES";
my $no_cache_setting = 'max-age=1, no-cache';
$self->hook(
after_dispatch => sub {
my $c = shift;

# Only process if file requested is under webwork2_files
return unless ($c->req->url->path =~ '^/webwork2_files/');

if ($c->req->url->path =~ '/tmp/renderer') {
# Treat problem generated files as already expired.
# They should not be cached.
$c->res->headers->cache_control($no_cache_setting);
$c->res->headers->header(
Expires => Mojo::Date->new(time - 86400) # expired 24 hours ago
);
} else {
# Standard "static" files.
# They can be cached
$c->res->headers->cache_control($cache_control_setting);
$c->res->headers->header(Expires => Mojo::Date->new(time + $STATIC_EXPIRES));
}
}
);
}

# Models
$self->helper(newProblem => sub { shift; RenderApp::Model::Problem->new(@_) });

Expand Down
1 change: 0 additions & 1 deletion render_app.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
webworkJWTsecret => 'private',
SITE_HOST => 'http://localhost:3000',
CORS_ORIGIN => '*',
STATIC_EXPIRES => 86400,
STRICT_JWT => 0,
FULL_APP_INSECURE => 0,
INTERACTION_LOG => 0,
Expand Down