Read about our upcoming Code of Conduct on this issue

Commit 1d5f0ca4 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis
Browse files

Merge branch '41601-document-pages-static-gzip' into 'master'

Resolve "I wonder how to leverage browser caching of my Gitlab pages?"

Closes #15037

See merge request gitlab-org/gitlab-ce!16829
......@@ -316,6 +316,47 @@ or various static site generators. Contributions are very welcome.
Visit the GitLab Pages group for a full list of example projects:
### Serving compressed assets
Most modern browsers support downloading files in a compressed format. This
speeds up downloads by reducing the size of files.
Before serving an uncompressed file, Pages will check whether the same file
exists with a `.gz` extension. If it does, and the browser supports receiving
compressed files, it will serve that version instead of the uncompressed one.
To take advantage of this feature, the artifact you upload to the Pages should
have this structure:
├─┬ index.html
│ └ index.html.gz
├── css/
│   └─┬ main.css
│ └ main.css.gz
└── js/
└─┬ main.js
└ main.js.gz
This can be achieved by including a `script:` command like this in your
`.gitlab-ci.yml` pages job:
# Other directives
- # build the public/ directory first
- find public -type f -iregex '.*\.\(htm\|html\|txt\|text\|js\|css\)$' -execdir gzip -f --keep {} \;
By pre-compressing the files and including both versions in the artifact, Pages
can serve requests for both compressed and uncompressed content without
needing to compress files on-demand.
### Add a custom domain to your Pages website
For a complete guide on Pages domains, read through the article
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment