206partial response is replayed for requests asking a different Range
2 months ago
With CDN caching enabled on a service, Railway's edge caches static media responses
keyed by URL only. It does not vary on the request Range header, and it caches
partial 206 responses.
The first request for a URL populates the cache; every later
request for that URL is served that exact cached body, even when its Range differs.
iOS Safari loads <audio>/<video> by first sending a 2-byte range probe
(Range: bytes=0-1) and then requesting the rest of the file. When the probe response
(206, 2 bytes) is what gets cached, the follow-up full-file request is served those
same 2 bytes, so the media element can never buffer enough to decode and playback
silently fails.
It is understandable you don't want the CDN to serve large video files, etc. The specific use case was small mp3 1-2s sound clips.
Env
server: railway-hikari,x-railway-edge: sin1, CDN caching enabled on the service ().- Django + WhiteNoise. The origin handles
Rangecorrectly and returns proper206responses on every cache MISS (application's own logs look completely healthy; the corruption only appears on an edge cache HIT)
Reproduced the "key on URL not range" behavior in both directions (probe, large range) and (large range, probe).
Please let me know if there is any configuration issue on my side that results in this behavior. If not (and if not already on the to-do list), please adjust cache to follow RFC 9111 3.3.
Thanks!
2 Replies
Status changed to Awaiting Railway Response Railway • about 2 months ago
2 months ago
This is confirmed CDN behavior, not a configuration issue on your side. The cache key is method + host + path + query string, and the Range header is not part of it, so a cached 206 is replayed verbatim for subsequent requests to the same URL regardless of the requested byte range.
As a workaround, you can have your origin return Cache-Control: no-store on those media responses so the edge skips caching them and each Range request reaches your service directly.
Status changed to Awaiting User Response Railway • about 2 months ago
Status changed to Solved noahd • about 2 months ago
a month ago
Hey, would just like to provide an update. We now fully support HTTP Range and Content-Range semantics on the CDN. Let me know if you have any questions.
Status changed to Awaiting User Response Railway • about 1 month ago
a month ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • about 1 month ago