From: Dan Scott Date: Sun, 2 Apr 2017 23:03:16 +0000 (-0400) Subject: Replace absolute cache control with ETag X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5be1ce1e459776e7ef1757d64f170c43ba8f5f4b;p=working%2FEvergreen.git Replace absolute cache control with ETag Hard-coding no-store / expires: -1 into the handler prevents the possibility of caching responses, which we might want for offline mode. We can use the ETag header to get clients to always try a network request; if they have connectivity, then the server will always return an updated response. Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 6aa1f5811d..6548edcd9e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -184,8 +184,7 @@ sub load { return $self->redirect_auth unless $self->editor->requestor; # Don't cache anything requiring auth for security reasons - $self->apache->headers_out->add("cache-control" => "no-store, no-cache, must-revalidate"); - $self->apache->headers_out->add("expires" => "-1"); + $self->apache->headers_out->add("cache-control" => "no-cache, must-revalidate"); return $self->load_email_record if $path =~ m|opac/record/email|; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm index da18d7e56d..65721d2a94 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm @@ -129,11 +129,16 @@ sub handler_guts { $vhost_processor_cache{$processor_key} = $tt; $ctx->{encode_utf8} = sub {return encode_utf8(shift())}; - unless($tt->process($template, {ctx => $ctx, ENV => \%ENV, l => $text_handler}, $r)) { + my $_out = ''; + unless($tt->process($template, {ctx => $ctx, ENV => \%ENV, l => $text_handler}, \$_out)) { $r->log->warn('egweb: template error: ' . $tt->error); return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; } + my $etag = md5_hex(Encode::encode_utf8($_out);) + $r->headers_out->add('Etag' => "\"$etag\""); + $r->print($_out); + return Apache2::Const::OK; }