Overview
Stringboot is built on three core principles: offline-first architecture, smart caching, and efficient synchronization. Understanding these concepts will help you build better localized applications.Three-Layer Cache Architecture
Stringboot uses a sophisticated three-layer caching system for optimal performance:1
Layer 1: In-Memory Cache
LRU, 1000 entries by default
Access: <1ms Cache miss2
Layer 2: Local Database
IndexedDB / Room / CoreData Not Found
3
Layer 3: Network Sync
String-Sync v2 with ETag
Access: 100-500msLayer 1: In-Memory Cache
Layer 1: In-Memory Cache
Fastest access - Strings are cached in memory for instant retrievalLRU Eviction - Least recently used strings are removed when cache is fullFrequency-based priority - Frequently accessed strings stay in cache longerPlatform-specific size: Configurable (default: 1000 entries)
Layer 2: Local Database
Layer 2: Local Database
Persistent storage - Survives app restarts and device rebootsFull offline capability - All synced strings available without networkTechnology: IndexedDB (Web), Room (Android), Core Data (iOS)Soft deletes - Removed strings are marked, not immediately deleted
Layer 3: Network Sync
Layer 3: Network Sync
String-Sync v2 Protocol - Efficient delta sync for changed strings onlyETag-based caching - Prevents unnecessary downloadsAutomatic retries - Failed requests retry with exponential backoffBackground sync - Non-blocking network operations
String-Sync v2 Protocol
Stringboot uses a custom delta synchronization protocol to minimize bandwidth and ensure fast updates.How Delta Sync Works
1
Metadata Check
Client sends stored ETag to server
2
Server Response
Case 1: No changes (304 Not Modified)Result: No download needed, cache is currentCase 2: Updates available (200 OK)
3
Download Delta
Client downloads only changed strings
4
Update Cache
SDK updates memory cache and local database with new strings
Bandwidth Savings
Traditional Approach
Every sync: Download full catalog (~100-500KB)Monthly bandwidth: ~3-15MB per user
String-Sync v2
Metadata check: ~2KBDelta download: Only changed stringsMonthly bandwidth: ~50-200KB per user
Offline-First Architecture
Stringboot is designed to work perfectly offline after the initial synchronization.Offline Behavior
- With Network
- Without Network
- SDK checks memory cache first
- Falls back to local database
- Syncs with server in background
- Updates cache with latest strings
Offline Capabilities
✓ All previously synced strings available
✓ Language switching works with cached languages
✓ No error messages or failed requests
✓ Zero latency - instant string retrieval
Smart Memory Management
Stringboot automatically manages cache based on access patterns and memory pressure.LRU Cache with Frequency Tracking
The SDK uses a Least Recently Used (LRU) cache enhanced with access frequency tracking:Platform-Specific Optimizations
- Web
- Android
- iOS
- Memory cache: 1000 entries
- IndexedDB: Unlimited storage (quota-based)
- Automatic cleanup on storage pressure
Language Management
Language Preloading
For instant language switching, preload languages into memory cache:Available Languages
Get list of languages with content:Error Handling & Fallbacks
Stringboot provides multiple fallback mechanisms to ensure your app always has content:Fallback Hierarchy
Network Error Handling
| Error Type | SDK Behavior |
|---|---|
| Network timeout | Use cached data, retry in background |
| 401/403 Unauthorized | Log error, use cache, disable sync |
| 404 Not Found | Language doesn’t exist, use fallback |
| 429 Rate Limited | Exponential backoff, max 3 retries |
| 500+ Server Error | Retry with backoff, use cache |
Performance Characteristics
Lookup Times
| Source | Typical Latency | Use Case |
|---|---|---|
| Memory cache | <1ms | Frequently accessed strings |
| Local database | 5-20ms | Previously synced strings |
| Network (cached) | 50-100ms | ETag check, no download |
| Network (delta) | 100-300ms | Download changed strings |
| Network (full) | 200-500ms | First sync or force refresh |
Best Practices
Do: Preload on Start
Preload common strings synchronously during app initialization
Don't: Force Refresh Often
Avoid bypassing ETag checks - wastes bandwidth
Do: Use Watchers/Hooks
Use reactive APIs for automatic UI updates
Don't: Poll for Updates
SDK handles sync automatically - no need to poll