I have several EC2 instances running as HTTP live origins for CloudFront distributions. I have everything configured and, for the most part, it works. I can push a stream to an origin and start watching via CloudFront usually without having to wait the first time. But if the encoder or the origin application is restarted, it often takes 3-5 minutes for the stream to become available at CloudFront’s edges again. During this time, I can pull up the stream directly from the origin, so I know that’s available, but CloudFront just doesn’t seem to see it.
Is this just the nature of using a CDN? Are there configuration settings either in Wowza or my CloudFront distribution I could look at to fix this?
To be clear: I am not referring to latency in the stream itself. I am talking about the time it takes from publishing a stream to my Wowza origin before it becomes watchable on CloudFront.
EDIT: I think I’ve found the problem. CloudFront caches 404 errors. If someone tries to watch the stream during the time that it is offline, the resulting 404 error will be cached in CloudFront by default for 5 minutes. To get around this, in your distribution settings, go to “Error Pages” and “Create Custom Error Response” (Don’t worry, you’re not actually creating a custom response.) Select 404 as the error type and set TTL to something small. Leave “Customize Error Response” as “No.” (Unless you do want a custom response, in which case, ignore my previous parenthetical statement.)
Still todo: Now I just need to figure out how to stop “x-cache: RefreshHit from cloudfront” for chunklist_*.m3u8 after the encoder restarts.