Skip to content
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

avoid caching the service worker for logged in users #3201

Merged
merged 1 commit into from Oct 9, 2020

Conversation

struan
Copy link
Member

@struan struan commented Oct 2, 2020

As the contents vary if the user is logged in and depending on their
permissions we should not be caching the service worker. This sets the
Vary header to 'Cookie' to avoid this.

@struan struan requested a review from dracos October 2, 2020 13:42
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, though caching always confuses me :) An alternative would be to Cache-Control: private or Cache-Control: max-age=0 (the latter apparently officially endorsed for SW: https://developers.google.com/web/updates/2019/09/fresher-sw ). But I think caching it for non-logged in people for a period of time (our reverse proxy would be an hour) is okay for our case, can always change in future. I assume it fixes your issue :)

@codecov
Copy link

codecov bot commented Oct 2, 2020

Codecov Report

Merging #3201 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3201   +/-   ##
=======================================
  Coverage   83.80%   83.80%           
=======================================
  Files         249      249           
  Lines       15803    15804    +1     
  Branches     2970     2970           
=======================================
+ Hits        13243    13244    +1     
  Misses       1621     1621           
  Partials      939      939           
Impacted Files Coverage Δ
perllib/FixMyStreet/App/Controller/Offline.pm 97.82% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d87d6b...fc4071d. Read the comment docs.

@struan struan requested a review from dracos October 6, 2020 12:30
@struan
Copy link
Member Author

struan commented Oct 6, 2020

Will squash this down to one commit before merging

As the contents of the service worker vary depending on if the user is
logged in don't cache it.
@struan struan merged commit fc4071d into master Oct 9, 2020
@github-pages github-pages bot temporarily deployed to github-pages October 9, 2020 13:06 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants