Skip to content

Enable gitlab-pages daemon to send precompressed .gz files as response if they are available

The idea is very simple and borrowed from ngx_http_gzip_static_module. Why? Because this will lower the required bandwidth for the pages sites and will help them load faster. Also serving precompiled gzip files will not require additional CPU resources on the server but only from the CI machine.

Basic steps:

  1. In the deployment phase of pages site we compress some resources with gzip;
  2. Later when the pages daemon servers requests it will check if the HTTP client accepts gzip compressed responses;
  3. If client accepts gzip responses and gzipped version exists serve him the precompressed gzip file;
  4. If client doesn't accept gzip response or given resource doesn't have precompressed gzip file serve the original file;

Required changes:

I don't know go code but it seem that only changing domain.go will need to be changed. The two functions serveFile and serveCustomFile could check for .gz version of the requested file if the HTTP request has Accept-Encoding: gzip and then serve it. If it doesn't exist try to serve the normal version. The unknown part (for me) is the handling of the Content-encoding: gzip for the response.

Some additional information: