Differential Updates
Instead of re-downloading your entire JavaScript bundle on every update, SwiftPatch compares the old bundle to the new one and delivers only what changed. The result: patches that are typically 50x to 360x smaller than a full download.
Think of it like a document redline -- instead of sending the whole document again, you just send the tracked changes.
Size Comparison
| Update Scenario | Full Bundle | Patch | Savings |
|---|---|---|---|
| Typo or copy fix | 18 MB | 12 KB | 99.9% |
| Small bug fix | 18 MB | 50 KB | 99.7% |
| Feature addition | 18 MB | 200 KB | 98.9% |
| Major refactor | 18 MB | 2 MB | 88.9% |
| First update (no baseline) | 18 MB | 18 MB | 0% |
The first update a device receives is always a full download. Every update after that uses differential patching automatically.
How It Works
Step 1: Compare -- The server diffs the new bundle against the version on the device.
Step 2: Generate -- A binary patch containing only changed bytes is created.
Step 3: Deliver -- The patch is compressed with Brotli (a compression algorithm, more efficient than gzip) and served from the CDN.
Step 4: Apply -- The device reconstructs the full bundle from the patch and its existing bundle, then verifies integrity.
Server Side
Device Side
The Algorithm
SwiftPatch uses a modified bsdiff algorithm optimized for JavaScript bundles:
- Binary-level diffing -- Operates on raw bytes for maximum compression
- JS-aware optimizations -- Tuned for minified and bundled JavaScript patterns
- Deterministic output -- Same inputs always produce the same patch
- Brotli compression -- Level 11 compression squeezes out every last byte
Benefits
| Benefit | Impact |
|---|---|
| Faster downloads | 50 KB loads in under 1 second, even on 3G |
| Lower bandwidth costs | 90-99% reduction in CDN egress |
| Better user experience | Silent background updates become practical |
| Cellular-friendly | Small patches do not penalize metered connections |
| Higher success rates | Smaller downloads mean fewer interrupted transfers |
What Happens If a Patch Fails?
The SDK verifies every patch with a SHA-256 hash check. If the reconstructed bundle does not match the expected hash, the device falls back to downloading the full bundle. Your users always get the correct update -- no matter what.
Hash verification cannot be disabled. This is a safety guarantee.