Cache Strategy
⚡ 5 min readConfigure how your PWA caches assets for offline use and faster loading
Caching Mode
| Mode | Description |
|---|---|
| Automatic | All files are loaded directly from the network. No caching rules applied. |
| Advanced | Customize caching rules per file type for faster, more reliable performance. |
Use Automatic for simple setups. Switch to Advanced when you need granular control over offline behavior and cache performance
Per-file Type Settings (Advanced)
When Advanced mode is enabled, you can configure caching separately for each asset type:
| File Type | Description |
|---|---|
| Script | JavaScript files |
| Styles | CSS files & styles |
| Images | JPG, PNG, SVG files |
| Navigation | HTML pages & routes |
| Fonts | WOFF, TTF font files |
| Media | Video & audio files |
Configuration Fields
For each file type, the following settings are available:
Pattern Type
| Option | Description |
|---|---|
| Route Pattern | Match URLs by route path |
| Regex Pattern | Match URLs using regular expressions for precise control |
Maximum Files
The maximum number of files of this type to cache. Example: 50
Expiration Time
| Option | Description |
|---|---|
| 1 Day | Cache expires after 1 day |
| 1 Week | Cache expires after 1 week |
| 1 Month | Cache expires after 1 month |
| Custom (Seconds) | Set a custom expiration in seconds |
Caching Strategy
| Strategy | Behavior |
|---|---|
| Cache First | Use cache if available; fetch from network only when not cached |
| Network First | Try network first; fall back to cache if network fails |
| Stale While Revalidate | Serve from cache immediately, then update cache in background |
| Network Only | Always fetch from network; never use cache |
Script-specific Settings
For Script (JavaScript files), you can use regex to control which files are cached:
- Default: All script files are cached locally
- Regex: Use a regular expression to include or exclude specific files
Example regex: .*\.script$ — matches files ending with .script
Next Steps
- Configuration - General configuration
- Surveillance - Monitoring and surveillance
Last updated on