Static Compression
Revela can pre-compress your static files with Gzip and Brotli for faster loading.
Do you need this? If you're using GitHub Pages, Netlify, Vercel, or Cloudflare Pages โ no! These platforms compress automatically. This plugin is for self-hosted servers, AWS S3, or basic web hosts.
Overview
๐ฆ Pre-Generated
Compressed files created at build time, not on every request.
๐ About 80% Smaller
HTML, CSS, and JS files shrink a lot with Brotli: about 80% for this website's own pages (HTML โ80%, CSS โ78%, JS โ69%).
โก No Work per Request
Servers send the pre-compressed files as they are instead of compressing every request.
Installation
The Standalone edition has Compress built in. In the Full edition, install it from the bundled packages:
revela plugin install Compress
Usage
Compress Your Site
# After generating your site
revela generate compress
Note: Compression runs separately, not as part of
generate all. Your server must be configured to serve pre-compressed files.
In a terminal, compression shows a live progress bar; in CI logs or redirected output it prints plain progress lines instead (one about every 10 %).
Running it again only compresses what changed. Revela keeps a .gz/.br file when the page it was made from has exactly the same content as last time and the compressed file itself is untouched; everything else is compressed again. The summary shows how many files were compressed and how many were unchanged.
Note:
revela generate pages(and thereforegenerate all) removes all compressed files before it writes new pages, so no outdated.gz/.brfile can be served. After such a build, the nextrevela generate compresscompresses everything again.
The local revela serve preview server automatically negotiates existing .br and .gz
variants using the browser's Accept-Encoding header. Production servers still need their
equivalent static Brotli/Gzip configuration.
Remove Compressed Files
revela clean compress
What Gets Compressed?
| File Type | Typical Savings |
|---|---|
| HTML | 70-85% |
| CSS | 75-90% |
| JavaScript | 65-80% |
| JSON | 70-85% |
| SVG | 50-70% |
| XML | 70-85% |
Images are skipped โ they're already optimized (AVIF, WebP, JPG).
Output Structure
Your files remain unchanged. Compressed versions are added alongside:
output/
โโโ index.html โ Original (10 KB)
โโโ index.html.gz โ Gzip (2.5 KB)
โโโ index.html.br โ Brotli (2.1 KB)
โโโ _assets/
โ โโโ main.css
โ โโโ main.css.gz
โ โโโ main.css.br
Revela remembers which .gz and .br files it created in .revela/compress/ownership.json in your project, not in the output, so that record is never uploaded with your site. Together with each file it stores a fingerprint of the page it was compressed from, which is how it recognises unchanged pages. revela clean compress removes only those files and never touches other .gz/.br files you put there yourself.
Example Output
โญโSuccessโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Compression complete! โ
โ โ
โ Summary: โ
โ Files: 14 โ
โ Compressed: 3 โ
โ Unchanged: 11 โ
โ Original: 1.22 MB โ
โ โ
โ Compressed sizes: โ
โ Gzip: 93.4 KB (92.5% savings) โ
โ Brotli: 61.6 KB (95.1% savings) โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
When Do You Need This Plugin?
| Platform | Need Plugin? | Reason |
|---|---|---|
| GitHub Pages | โ No | Compresses automatically |
| Netlify | โ No | Compresses automatically |
| Vercel | โ No | Compresses automatically |
| Cloudflare Pages | โ No | Compresses automatically |
| AWS S3 + CloudFront | ๐ก Optional | CloudFront compresses, but pre-compressed is faster |
| AWS S3 (direct) | โ Yes | No automatic compression |
| nginx | โ Yes | Use gzip_static on for pre-compressed files |
| Apache | โ๏ธ Needs RewriteRule |
Pipeline Order
Compression is not part of revela generate all. Run it separately after generating your site:
revela generate all
revela generate compress
This ensures all content exists before compressing.
Compression Settings
The plugin uses maximum compression for smallest files:
| Format | Level | Browser Support |
|---|---|---|
| Gzip | 9 (max) | All browsers |
| Brotli | 11 (max) | Modern browsers (95%+) |
Files under 256 bytes are skipped โ compression overhead exceeds savings.
Server Configuration
Pre-compressed files only help if your server serves them. Point your server at the .gz / .br files:
nginx
gzip_static on;
brotli_static on; # requires the ngx_brotli module
Apache
# Serve .br to Brotli-capable browsers
RewriteCond %{HTTP:Accept-Encoding} br
RewriteCond %{REQUEST_FILENAME}.br -f
RewriteRule ^(.*)$ $1.br [L]
# Serve .gz to Gzip-capable browsers
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [L]
Caddy / GitHub Pages / Netlify / Cloudflare Pages
These serve pre-compressed files automatically โ no configuration needed.