You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: Use `app()->booted()` to ensure the application is fully booted and the cache is accessible.
125
+
126
+
Note 2: The `all()` method can never return an empty array, if you've at least once successfully run `cloudflare:refresh`. Read more about the caching design below.
127
+
110
128
4. Use the `cache-info` command to see information about the currently cached IPs.
To avoid network calls during request handling and still remain resilient if Cloudflare is temporarily unreachable, the package maintains two cache layers:
150
+
151
+
* current – the actively refreshed list with a configurable TTL (default 7 days).
152
+
* last_good – a permanent (forever) copy updated only after a fully successful refresh (both IPv4 and IPv6 lists fetched). It is never cleared on a failed refresh.
153
+
154
+
Lookup order for `ipv4()`, `ipv6()`, and `all()`:
155
+
1. current list
156
+
2. last_good list (when `allow_stale` is true)
157
+
3. (logs a warning and returns an empty array only if neither exists – typically only before the very first refresh)
158
+
159
+
Advantages:
160
+
* No request latency spikes from on-demand fetching.
161
+
* Transient network failures do not drop trusted proxy IPs – the last_good list continues to be served.
162
+
* Safe refresh semantics: last_good updates only after a fully successful fetch of both families.
*`cache.ttl` – lifetime for current list (seconds, null = forever).
166
+
*`cache.allow_stale` – whether to fall back to last_good when current missing.
167
+
* Distinct key sets under `cache.keys.current` and `cache.keys.last_good`.
168
+
169
+
Operational recommendation:
170
+
* Run `cloudflare:refresh` in your deployment pipeline and via the scheduler. A single success seeds both caching layers.
171
+
* Keep the TTL of last_good infinite (null) to ensure a fallback is always available.
172
+
* Regularly check logs and use `cloudflare:cache-info` to monitor cache status.
173
+
129
174
## Using with Laravel Octane
130
175
131
176
When you use this package to trust Cloudflare proxies via the `TrustProxies` middleware, while running behind Laravel Octane, keep the following in mind:
0 commit comments