Skip to content

Instant WebView via preloading and caching webpage

Notifications You must be signed in to change notification settings

makdv/InstantWebViewApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

InstantWebViewApp

High-performance iOS WebView application with smart caching strategies.

Features

  • 🚀 Instant Loading: WebView preloads in background
  • 💾 Smart Caching: Multiple caching strategies (stale-while-revalidate, session cache, etc.)
  • Native Performance: 60 FPS smooth scrolling
  • 🔄 Background Revalidation: Updates cache without blocking UI
  • 🎯 Production Ready: Error handling, loading states, proper memory management

Caching Strategies

  1. Always Fresh - Always load from server (no cache)
  2. Session Cache - Cache for N minutes
  3. Stale-While-Revalidate - Show cached + update in background (recommended)
  4. Revalidate On Close - Update cache when closing WebView

Installation

Requirements

  • macOS with Xcode 14.0+
  • iOS 15.0+ (deployment target)
  1. Open the project:
   open InstantWebViewApp.xcodeproj
  1. Configure your web app URL:
   // In InstantWebViewAppApp.swift
   let WEB_APP_URL = "https://your-app.com"
  1. Select a simulator and run (Cmd + R)

Configuration

Change Caching Strategy

// In InstantWebViewAppApp.swift
let CACHE_STRATEGY: CacheStrategy = .staleWhileRevalidate  // Change this
let CACHE_DURATION_MINUTES = 15  // Cache lifetime

Available Strategies

  • .alwaysFresh - Development mode
  • .sessionCache - Balanced approach
  • .staleWhileRevalidate - Best UX (recommended)
  • .revalidateOnClose - Resource efficient

Architecture

  • SwiftUI - Modern declarative UI
  • WKWebView - High-performance web rendering
  • Combine - Reactive state management
  • Background WebView - Silent revalidation

Performance

  • First open: 0-2 seconds (depending on page)
  • Subsequent opens: Instant (< 100ms)
  • Cache persistence: Across app sessions
  • Memory efficient: Process pool reuse

About

Instant WebView via preloading and caching webpage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages