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

🚀 feat: Enhance PWA and asset caching strategy #3822

Merged
merged 2 commits into from
Aug 28, 2024
Merged

Conversation

danny-avila
Copy link
Owner

Summary

  • Updated the VitePWA registerType from 'prompt' to 'autoUpdate' in the Vite configuration file. This change ensures that the service worker automatically updates in the background, providing users with the most recent version of the app without manual intervention.
  • Added cache busting to static file outputs by implementing hash-based filenames for entry files, chunk files, and asset files. This strategy prevents browsers from serving outdated cached versions of our assets.
  • Configured entryFileNames, chunkFileNames, and assetFileNames in the Vite build options to include content hashes in the file names. This approach ensures that each new build generates uniquely named files, forcing browsers to download the latest versions.

Testing:
To test these changes, I recommend the following steps:

  1. Build the application and deploy it to a test environment.
  2. Load the application in a browser and verify that the service worker registers automatically.
  3. Make a small change to the application, rebuild, and redeploy.
  4. Reload the application in the browser and confirm that the new version is automatically downloaded and applied without user intervention.
  5. Inspect the network requests to ensure that the new asset files are being fetched with their updated hash-based filenames.

These modifications should result in a more seamless update process for our PWA and better caching behavior for our static assets. Users will benefit from always having the most up-to-date version of the application without manual intervention.

@danny-avila danny-avila changed the title feat: Enhance PWA and asset caching strategy 🚀 🚀 feat: Enhance PWA and asset caching strategy Aug 28, 2024
@danny-avila danny-avila merged commit 3b61322 into main Aug 28, 2024
1 check passed
@danny-avila danny-avila deleted the chore/vite-config branch August 28, 2024 16:13
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.

1 participant