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 2d87d6b commit fc4071d
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 @@ -36,6 +36,7 @@
- Do not strip spaces from middle of Open311 category codes. #3167
- Show all category history even if category renamed.
- Fix email alert on initial update template.
- 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 fc4071d

Please sign in to comment.