Partial Content support for Range: Requests

A customer has reported an issue with their self-managed GitLab Pages install that is hosting a ranged .mp4 file.

The file is viewable in browsers other than Safari - which just shows an error icon

Look at the Request Header - Safari is requesting a Range:

Request
Range: bytes=0-1
Accept: */*
Referer: [customer pages URL]
Accept-Encoding: identity
Connection: Keep-Alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15
X-Playback-Session-Id: 1041C23E-9805-4A77-8474-0DD68C50E906

Response
Vary: Origin
Date: Fri, 13 Nov 2020 19:22:55 GMT
Content-Type: video/mp4
Content-Length: 144220
Cache-Control: max-age=600
Expires: Fri, 13 Nov 2020 19:32:55 UTC

And from their developer docs appears to require that the server support 206 Partial Content responses. (h/t this stack overflow comment )

I'm unclear if the work to add the httprange package in #333 might lay the foundation for supporting this.

Solution

Documented in https://docs.gitlab.com/ee/user/project/pages/introduction.html#cannot-play-media-content-on-safari

Enabling fastest compression level

Enable ARTIFACT_COMPRESSION_LEVEL: "fastests" and FF_USE_FASTZIP: "true" for Pages to serve ranged requests. GitLab Runner 13.9+ required.

For GitLab Pages to serve HTTP Range requests, artifacts should use the ARTIFACT_COMPRESSION_LEVEL: fastest setting, as only uncompressed zip archives support this feature.

Sample working project

stages:
  - deploy

pages:
  stage: deploy
  variables:
    FF_USE_FASTZIP: "true"
    ARTIFACT_COMPRESSION_LEVEL: "fastest"
  script:
    - echo "Deploying pages"
  artifacts:
    paths:
      - public
Edited by Jaime Martinez