如何为Gitlab页面启用GZip压缩? [英] How to enable GZip compression for Gitlab Pages?

查看:254
本文介绍了如何为Gitlab页面启用GZip压缩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Gitlab页面渲染我的网站时,页面排名缓慢。我在GitLab(<企业版非企业版)

When using Gitlab Pages to render my site which is slow in page-ranking. I can't find any solution on how to do following in GitLab (non-enterprise version)


  1. 为各种页面资源(如图像)指定 HTTP缓存标题,以便可以对其进行缓存。

  1. Specify HTTP Cache Headers for various page resources like for an image, so that it can be cached.

指定/启用GZip压缩,因为页面排名提到了gitlab.io中禁用的压缩。

Specify/Enable compression for GZip as page-ranking mentions compression disabled in gitlab.io.


推荐答案


  1. 似乎仍然无法指定HTTP缓存头。但是至少他们已经为所有资源 max-age = 600 = nofollow noreferrer>此处。

  2. 您可以通过 .gitlab-ci压缩 public 文件夹的内容。 yml

  1. It looks like specifying HTTP Cache Headers is still not possible. But at least they have hardcoded "max-age=600" for all the resources here.
  2. You can compress contents of your public folder via .gitlab-ci.yml:

脚本:


  • npm install

  • npm运行构建

  • gzip -k -6 -r public

这篇关于如何为Gitlab页面启用GZip压缩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆