Skip to content

Commit

Permalink
do not cache the service worker
Browse files Browse the repository at this point in the history
As the contents of the service worker vary depending on if the user is
logged in don't cache it.
  • Loading branch information
struan committed Oct 9, 2020
1 parent 57f4048 commit 34875fe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Fix a few obscure asset layer changing issues.
- Fix multiple disable messages for dropdown answers
- Do not trigger duplicate check when checking stoppers
- Do not cache the service worker
- Admin improvements:
- Display user name/email for contributed as reports. #2990
- Interface for enabling anonymous reports for certain categories. #2989
Expand Down
1 change: 1 addition & 0 deletions perllib/FixMyStreet/App/Controller/Offline.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Offline pages Catalyst Controller - service worker handling

sub service_worker : Path("/service-worker.js") {
my ($self, $c) = @_;
$c->res->headers->header('Cache-Control' => 'max-age=0');
$c->res->content_type('application/javascript');
}

Expand Down
1 change: 1 addition & 0 deletions t/app/controller/offline.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ FixMyStreet::override_config {

subtest 'service worker' => sub {
$mech->get_ok('/service-worker.js');
is $mech->res->header('Cache-Control'), 'max-age=0', 'service worker is not cached';
$mech->content_contains('translation_strings');
$mech->content_contains('offline/fallback');
};
Expand Down

0 comments on commit 34875fe

Please sign in to comment.