A React-based Progressive Web App (PWA) implemented with Vite, showcasing various caching strategies using Workbox. This repository demonstrates how to configure and utilize caching strategies to optimize performance and offline capabilities in a PWA.
- React and Vite Integration: Fast and modern development setup using Vite and React.
- Service Worker Setup: Configured with Workbox for efficient caching and offline capabilities.
- Versioned Service Worker: Implements versioning to manage service worker updates and cache invalidation.
- Custom Caching Strategies: Demonstrates different caching strategies including
CacheFirst,StaleWhileRevalidate, and runtime caching. - Asset Caching: Pre-caches static assets like JavaScript, CSS, HTML, and images.
- Specific Asset Caching: Example of caching specific assets like
/images/pwa.pngwith custom expiration policies. - PWA Manifest: Configured manifest file with app icons, theme color, and display options for a better user experience.
- Node.js (>=18.x)
- npm (>=6.x) or yarn
- Clone the repository:
git clone https://github.com/ablfaxl/pwa-cache-strategies.git
- Navigate to the project directory:
cd pwa-cache-strategies - Install the dependencies:
npm install # or yarn install # or pnpm install
To start the development server:
npm run dev
# or
yarn dev
# or
pnpm devTo start the production server:
npm run build
npm run preview
# or
yarn build
yarn preview
# or
pnpm build
pnpm preview