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

add Vite PWA plugin #386

Merged
merged 17 commits into from
Jul 5, 2023
Merged

add Vite PWA plugin #386

merged 17 commits into from
Jul 5, 2023

Conversation

incognitojam
Copy link
Collaborator

@incognitojam incognitojam commented Jul 5, 2023

The service worker will check for updates on page load, downloading them in the background ready to present on the next page load.

  • Test update
  • Double check that you do not have caching features enabled, especially immutable, on locations like:
    • /
    • /sw.js
    • /index.html
    • /manifest.webmanifest
$ curl -s -I -X GET localhost:3000/index.html
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Wed, 05 Jul 2023 15:09:06 GMT
Content-Type: text/html
Content-Length: 4612
Last-Modified: Wed, 05 Jul 2023 15:07:18 GMT
Connection: keep-alive
Vary: Accept-Encoding
Cache-Control: public, max-age=0, s-maxage=0, must-revalidate
Accept-Ranges: bytes

https://vite-pwa-org.netlify.app/deployment/nginx.html
Running production nginx server using docker compose, test command: curl -s -I -X GET localhost:3000/index.html

@github-actions
Copy link

github-actions bot commented Jul 5, 2023

Size Change: -164 kB (-29%) 🎉

Total Size: 399 kB

Filename Size Change
./dist/assets/explorer.js 351 kB +12.4 kB (+4%)
./dist/assets/index.js 1.89 kB -176 kB (-99%) 🏆
./dist/assets/SwitchLoading.js 21.2 kB +447 B (+2%)
ℹ️ View Unchanged
Filename Size Change
./dist/assets/anonymous.js 5.1 kB +1 B (0%)
./dist/assets/explorer.css 3.42 kB 0 B
./dist/assets/index.css 5.16 kB -12 B (0%)
./dist/assets/NoDeviceUpsell.js 794 B -2 B (0%)
./dist/assets/qr-scanner-worker.min.js 10.2 kB 0 B

compressed-size-action

@incognitojam incognitojam marked this pull request as ready for review July 5, 2023 14:24
@incognitojam
Copy link
Collaborator Author

Service worker downloads update in the background... (since I reverted the last commit, those files were already in the disk cache!). New code is used on next page reload.
image

@incognitojam
Copy link
Collaborator Author

vite-pwa-plugin automatically generates the service worker code, including the list of resources to pre-fetch (the contents of the dist folder from the build)
image
image

@incognitojam incognitojam merged commit d431d97 into master Jul 5, 2023
5 checks passed
@incognitojam incognitojam deleted the pwa branch July 5, 2023 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant