Skip to content

Commit f8c97f3

Browse files
PeterCxykcmartin
andauthored
Add docs for fly-replay-cache-control and fly-replay-cache-status (#2216)
* Add docs for `fly-replay-cache-control` and `fly-replay-cache-status` * Apply suggestions from code review Co-authored-by: Kristin Martin <[email protected]> * More suggestions --------- Co-authored-by: Kristin Martin <[email protected]>
1 parent 93e7ae3 commit f8c97f3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

networking/dynamic-request-routing.html.markerb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,39 @@ The app issuing `fly-replay` still serves as the ultimate source of truth, and w
168168
To ensure reliable operation, the app issuing `fly-replay` should still have multiple instances deployed in multiple regions.
169169
</div>
170170

171+
### Bypassing the replay cache
172+
173+
Sometimes, you might want a client to bypass a cached replay without actually invalidating the cache.
174+
For example, you might have an API endpoint that _mostly_ needs to be replayed to a "leader" instance. But depending on application logic, it could sometimes be handled by any instance.
175+
176+
The recommended approach is to clearly separate endpoints that require replay from those that don't.
177+
However, when that is not possible, the replaying app can additionally set the header
178+
179+
```
180+
fly-replay-cache-allow-bypass: yes
181+
```
182+
183+
or set the JSON field `"allow_bypass": true`. Then, when your client makes a request, it can set the header:
184+
185+
```
186+
fly-replay-cache-control: skip
187+
```
188+
189+
to skip any cached replay that might be present.
190+
191+
<div class="note icon">
192+
**Note**: This behavior is opt-in because enabling it by default could make your app vulnerable to malicious clients creating unexpected load on the replaying machine. All it takes is setting a boolean HTTP header.
193+
</div>
194+
195+
### Was my request served by the cache?
196+
197+
If your app needs to know whether a request was served from the replay cache, it can check the fly-replay-cache-status header. This header is sent to the replay _target_ app or machine.
198+
199+
- Absent: the request was not replayed and was delivered directly to the app or machine.
200+
- `miss`: the request didn't use replay cache; it first hit another machine and got replayed here.
201+
- `hit`: the request did use the replay cache! It never reached the source app or machine and was redirected straight to the target.
202+
- `bypass`: even though the cache might have been set, it was explicitly skipped by setting the `fly-replay-cache-control: skip` header.
203+
171204
## Implementation Details
172205

173206
### Requirements and Limitations

0 commit comments

Comments
 (0)