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)
Specify HTTP Cache Headers
for various page resources like for an image, so that it can be cached.
Specify/Enable compression for GZip as page-ranking mentions compression disabled in gitlab.io.
Gzip on Windows Servers (IIS Manager) Open up IIS Manager. Click on the site you want to enable compression for. Click on Compression (under IIS) Now Enable static compression and you are done!
GitHub Pages currently support on-the-fly gzip compression. Since it's resource-intensive, usually the compression level is not set to high/max. Users can instead opt for pre-compressing the assets using the maximum compression level.
You can enable GZIP Compression on your site server by using, mod-deflate, or mod-zip method. If you are a professional coder, then you must have an idea that the deflate method has more advantages over mod-zip, as it compresses the output from your server before it is being sent to your user's browser.
GitLab Pages will serve pre-compressed .gz files that exist alongside uncompressed equivalents. A general solution that should work with most static publishing systems is to put this as the last step in the build process in .gitlab-ci.yml:
Enter the URL to a webpage or resource, and type in gzip under "Accept-Encoding" to indicate that the HTTP client (i.e., the online testing tool in this case) accepts gzip compression, as most browsers do. You might review the other information and suggestions here to optimize serving as well.
To use GitLab Pages, you must create a project in GitLab to upload your website’s files to. These projects can be either public, internal, or private. GitLab always deploys your website from a very specific folder called public in your repository. When you create a new project in GitLab, a repository becomes available automatically.
Introduced in GitLab 14.7. Reconfigure GitLab. You can also find the log file in /var/log/gitlab/gitlab-pages/current. It means you didn’t set the HTTP (S) protocol scheme in the Pages server settings. To fix it: In some cases, NGINX might default to using IPv6 to connect to the GitLab Pages service even when the server does not listen over IPv6.
You can compress contents of your public folder via .gitlab-ci.yml:
script:
GitLab has support for serving compressed assets if you pre-compress them in the pages
CI Job already. See the documentation.
Note that you can and also should use brotli
compression as it's optimized for web content and supported by most modern browsers.
There is also a suggested snippet for your .gitlab-ci.yml
:
pages:
# Other directives
script:
# Build the public/ directory first
- find public -type f -regex '.*\.\(htm\|html\|txt\|text\|js\|css\)$' -exec gzip -f -k {} \;
- find public -type f -regex '.*\.\(htm\|html\|txt\|text\|js\|css\)$' -exec brotli -f -k {} \;
I haven't found a way of influencing cache behavior. I am also looking for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With