Skip to content

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:

  1. Application cache (when warm)
  2. Last-known-good cache entries (hybrid / fallback)
  3. Bundled archives (bundled mode, or hybrid fallback)
  4. A controlled refresh path when the cache TTL expires (runtime / hybrid), typically via edge-trust:sync or 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),
],
KeyPurpose
storeLaravel cache store name; null uses the default
prefixPrefix for EdgeTrust cache keys
ttlFresh cache lifetime in seconds
stale_ttlHow long last-known-good data may be retained
lock_secondsSync 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=cloudflare

Clears EdgeTrust cache entries so the next resolution reloads from archives and/or sources according to the configured mode.

Interaction with modes ​

ModeCache role
bundledCaches parsed archive data; no remote fetch
runtimeCaches successful fetches until TTL
hybridCaches 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.

Released under the MIT License.