summaryrefslogtreecommitdiff
path: root/doc/user/project/pages/introduction.md
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-01-31 12:54:19 +0000
committerNick Thomas <nick@gitlab.com>2018-01-31 15:19:29 +0000
commit08d1a6bb13489b982dfc4b66c8f856f018c9e235 (patch)
tree91da42a3cab70666350a08b8afecb7d1f53c37cd /doc/user/project/pages/introduction.md
parent08e013431acb5238b4806260c4b9c304837097a3 (diff)
downloadgitlab-ce-08d1a6bb13489b982dfc4b66c8f856f018c9e235.tar.gz
Add documentation about serving pre-compressed assets in GitLab Pages
Diffstat (limited to 'doc/user/project/pages/introduction.md')
-rw-r--r--doc/user/project/pages/introduction.md41
1 files changed, 41 insertions, 0 deletions
diff --git a/doc/user/project/pages/introduction.md b/doc/user/project/pages/introduction.md
index f52f66f518a..0b5076b8c5d 100644
--- a/doc/user/project/pages/introduction.md
+++ b/doc/user/project/pages/introduction.md
@@ -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:
<https://gitlab.com/groups/pages>.
+### 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:
+
+```
+public/
+├─┬ 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:
+
+```yaml
+pages:
+ # Other directives
+ script:
+ - # 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