Caching
EdgeTrust caches resolved proxy ranges so request handling stays fast and provider endpoints are not hammered.
Never fetch on every request
HTTP fetches of provider IP lists are not performed on every incoming HTTP request. Resolution uses:
- Application cache (when warm)
- Last-known-good cache entries (hybrid / fallback)
- Bundled archives (bundled mode, or hybrid fallback)
- A controlled refresh path when the cache TTL expires (runtime / hybrid), typically via
edge-trust:syncor the scheduled sync job
That refresh is driven by cache expiry and Artisan sync — not by attaching a remote HTTP call to the TrustProxies middleware hot path.
Configuration
php
'cache' => [
'store' => env('EDGE_TRUST_CACHE_STORE', null), // null = default cache store
'prefix' => env('EDGE_TRUST_CACHE_PREFIX', 'edge-trust'),
'ttl' => (int) env('EDGE_TRUST_CACHE_TTL', 60 * 60 * 24),
'stale_ttl' => (int) env('EDGE_TRUST_CACHE_STALE_TTL', 60 * 60 * 24 * 7),
'lock_seconds' => (int) env('EDGE_TRUST_SYNC_LOCK', 120),
],| Key | Purpose |
|---|---|
store | Laravel cache store name; null uses the default |
prefix | Prefix for EdgeTrust cache keys |
ttl | Fresh cache lifetime in seconds |
stale_ttl | How long last-known-good data may be retained |
lock_seconds | Sync lock duration to avoid stampedes |
Point store at Redis (or another shared store) when you run multiple app servers so they share warm ranges.
Clearing cache
bash
php artisan edge-trust:clear
php artisan edge-trust:clear --provider=cloudflareClears EdgeTrust cache entries so the next resolution reloads from archives and/or sources according to the configured mode.
Interaction with modes
| Mode | Cache role |
|---|---|
bundled | Caches parsed archive data; no remote fetch |
runtime | Caches successful fetches until TTL |
hybrid | Caches successful fetches; on miss/failure uses last-known-good, then archive |
Operational tips
- Prefer a TTL of several hours or a full day for production — CDN IP lists change infrequently.
- After
edge-trust:sync, workers pick up new data from cache / archives according to mode. - Do not disable caching for runtime sources in high-traffic apps; doing so defeats the design and risks rate limits or latency spikes.