Skip to content

Conversation

@upayanmazumder
Copy link
Member

This pull request refactors and improves the service-worker.js file, focusing on code clarity, error handling, and caching strategies. The changes enhance reliability, make the code more maintainable, and improve offline support for users.

Caching and Fetch Handling Improvements:

  • Improved error handling when caching core assets during installation, logging failures instead of failing silently.
  • Enhanced fetch event logic:
    • Core assets now use a cache-first strategy with improved offline fallback.
    • Navigation requests use a network-first strategy with robust offline fallback and error logging.
    • Other runtime requests use a network-first strategy, cache successful responses with a timestamp header, prune the runtime cache, and provide better offline fallback.

Code Structure and Readability:

  • Added clear section dividers and comments to organize the code into logical blocks (install, activate, fetch, etc.).
  • Reformatted the CORE_ASSETS array for readability.

Cache Management Enhancements:

  • Refined the runtime cache pruning logic to remove expired and excess entries more efficiently, using parallel deletion and improved filtering.
  • Improved activation logic for deleting old caches, making it more concise and readable. (F8f62ce1L

@vercel
Copy link

vercel bot commented Oct 21, 2025

@upayanmazumder is attempting to deploy a commit to the GDSC VIT's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the service worker to improve error handling, caching strategies, and code maintainability. Key changes include enhanced offline fallback support, more efficient cache management, and better code organization.

Key changes:

  • Implemented cache-first strategy for core assets and network-first strategy for navigation/runtime requests with comprehensive offline fallbacks
  • Enhanced runtime cache pruning using parallel deletion and improved filtering logic
  • Added error logging for failed cache operations and network requests

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@upayanmazumder upayanmazumder merged commit 077a978 into GDGVIT:dev Oct 21, 2025
1 of 3 checks passed
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