Wednesday, 21 August 2013

Reverse HTTP proxy as CDN origin server, how to handle last modified since?

Reverse HTTP proxy as CDN origin server, how to handle last modified since?

I'm trying to set up redundant origin servers for a CDN that will deliver
on demand video files. The current setup is that I have two "media"
servers that have a large storage capacity and are running nginx. In front
of those two servers is another nginx server that is setup as a reverse
proxy, splitting requests to each of them.
Duplicates copies of each video are stored on each media server. They are
copied to each media server but may occur at slightly different times.
Because of that, nginx will return slightly different LastModified headers
for requests for the videos, depending on which nginx server served it.
The problem is, the CDN that caches the data will sometimes send IMS (If
Modified Since) requests to the origin server, and will use that
information to determine if it needs to refresh the video in its cache.
The CDN makes byte range requests for the videos, which could easily be
split between the two servers. If the byte range requests continue to get
different last modified headers, everything gets screwed up.
Is this a solvable problem? Do I need to use some other mechanism for
keeping the data between the two servers "in sync"? Maybe I can use rsync
to copy the data from one storage server to the other, and pass in an
option that preserves all the creation/modified times?

No comments:

Post a Comment