Qasar Younis

Aggressive Caching Strategy

Aggressive Caching Strategy

šŸŽÆ Philosophy

Most content on the site is static and rarely changes, so we use very aggressive caching for maximum performance.

šŸ“Š Cache Durations

Static Assets (1 Year)

HTML Pages (24 Hours)

Writings Page (6 Hours)

Favicon (1 Month)

šŸš€ How It Works

First Visit:

Repeat Visits (< 24 hours):

After 24 Hours:

Writings Page Special Handling:

šŸ“ When Content Updates

Photos Update (coming in a few weeks):

  1. Update photos
  2. Update service worker version: const CACHE_NAME = 'qyco-v1.0.1';
  3. Deploy
  4. Users get new photos automatically

New Essay Added:

  1. Add new essay markdown file
  2. Deploy
  3. Writings page updates within 6 hours (or immediately if user refreshes)
  4. Service worker updates cache in background

Other Content Updates:

šŸŽÆ Performance Impact

Content Type Cache Duration Update Frequency User Experience
Images/CSS/JS 1 year Never Instant forever
HTML Pages 24 hours Rarely Instant, updates within 24h
Writings 6 hours Few times/year Instant, updates within 6h
Favicon 1 month Rarely Instant

āœ… Benefits

  1. Maximum Performance: Repeat visits are instant (< 100ms)
  2. Reduced Bandwidth: Less data transferred
  3. Better UX: Site feels like a native app
  4. Offline Support: Site works offline
  5. Smart Updates: Writings page checks for updates in background

šŸ”§ Force Cache Refresh

If you need to force users to see updates immediately:

  1. Update Service Worker Version:
    // In sw.js
    const CACHE_NAME = 'qyco-v1.0.1'; // Increment version
    
  2. Deploy: Users automatically get new version

  3. Alternative: Users can hard refresh (Ctrl+Shift+R / Cmd+Shift+R)

šŸ“ˆ Expected Results

šŸŽ‰ Result

Your site now loads instantly on repeat visits, with smart background updates for content that changes occasionally!

The aggressive caching strategy is perfect for a mostly-static site like yours, where content rarely changes but you want maximum performance.