Skip to content


Repository files navigation


Swift CocoaPods Build Status CodeCov

A simple local reverse proxy server for HLS segment cache.

How it works

HLSCachingReverseProxyServer Concept

  1. User sets a reverse proxy url to the AVPlayer instead of the origin url.
  2. AVPlayer requests a playlist(.m3u8) to the local reverse proxy server.
  3. Reverse proxy server fetches the origin playlist and replaces all URIs to point the localhost.
    - vod_00001.ts
    - vod_00002.ts
    - vod_00003.ts
  4. AVPlayer requests segments(.ts) to the local reverse proxy server.
  5. Reverse proxy server fetches the origin segment and caches it. Next time the server will return the cached data for the same segment.


let server = HLSCachingReverseProxyServer()
server.start(port: 8080)

let playlistURL = URL(string: "")!
let reverseProxyURL = server.reverseProxyURL(from: playlistURL)!
let playerItem = AVPlayerItem(url: reverseProxyURL)
self.player.replaceCurrentItem(with: playerItem)



Use CocoaPods with Podfile:

pod 'HLSCachingReverseProxyServer'


$ make project
$ open HLSCachingReverseProxyServer.xcworkspace


HLSCachingReverseProxyServer is under MIT license. See the LICENSE for more info.