Skip to main content

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 ScenarioFull BundlePatchSavings
Typo or copy fix18 MB12 KB99.9%
Small bug fix18 MB50 KB99.7%
Feature addition18 MB200 KB98.9%
Major refactor18 MB2 MB88.9%
First update (no baseline)18 MB18 MB0%
info

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

BenefitImpact
Faster downloads50 KB loads in under 1 second, even on 3G
Lower bandwidth costs90-99% reduction in CDN egress
Better user experienceSilent background updates become practical
Cellular-friendlySmall patches do not penalize metered connections
Higher success ratesSmaller 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.

warning

Hash verification cannot be disabled. This is a safety guarantee.