Skip to content

PWA Service Workers #718

Open
samikabhatkar-web wants to merge 3 commits into
devfrom
707/pwa-service-workers
Open

PWA Service Workers #718
samikabhatkar-web wants to merge 3 commits into
devfrom
707/pwa-service-workers

Conversation

@samikabhatkar-web
Copy link
Copy Markdown
Contributor

Summary

Adds Next.js static asset and CSS caching to the service worker

Changes

  • Added /_next/static/ to the static assets cache block to catch Next.js compiled CSS and JS chunks
  • Added install event listener to pre-cache the app shell and icons on service worker install
  • Added fetchAndCache and isCacheFresh helper functions for reusable caching logic
  • Added fetch event listener

Testing Instructions

  • Dev tools -> Application -> Cached storage
    *Although, I think next.js might not be handling the service workers

Closes #

Copy link
Copy Markdown
Collaborator

@TheAbubakrAbu TheAbubakrAbu left a comment

Choose a reason for hiding this comment

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

Great job guys!

But one small thing, ratings is currently using NETWORK_FIRST. Because ratings can change frequently and stale ratings could be misleading, I think we should move ratings into the NEVER_CACHE block like what you did with favorites.

@samikabhatkar-web
Copy link
Copy Markdown
Contributor Author

Great job guys!

But one small thing, ratings is currently using NETWORK_FIRST. Because ratings can change frequently and stale ratings could be misleading, I think we should move ratings into the NEVER_CACHE block like what you did with favorites.

Sounds good, I moved the user-specific ones (dish.rated, user.getUserRating) to NEVER_CACHE and leftdish.getAverageRating in NETWORK_FIRST.

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.

3 participants