https://github.com/pmh-only/caddy-minify
:triangular_ruler: File (html/css/js/etc..) minification module for Caddy v2
https://github.com/pmh-only/caddy-minify
caddy-plugin caddy2 minification
Last synced: 8 months ago
JSON representation
:triangular_ruler: File (html/css/js/etc..) minification module for Caddy v2
- Host: GitHub
- URL: https://github.com/pmh-only/caddy-minify
- Owner: pmh-only
- Created: 2023-11-25T02:24:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-30T05:56:25.000Z (over 2 years ago)
- Last Synced: 2025-04-12T13:32:49.016Z (about 1 year ago)
- Topics: caddy-plugin, caddy2, minification
- Language: Go
- Homepage:
- Size: 169 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# File (html/css/js/etc..) minification module for Caddy v2

powered by [tdewolff/minify](https://github.com/tdewolff/minify) & inspired by [hacdias/caddy-v1-minify](https://github.com/hacdias/caddy-v1-minify)
## Caddy module ID
```
http.handlers.minify
```
## Support formats
* html: `text/html`
* css: `text/css`
* svg: `image/svg+xml`
* js: `^(application|text)/(x-)?(java|ecma)script$`
* json: `[/+]json$`
* xml: `[/+]xml$`
## Performance
See https://github.com/tdewolff/minify#performance
## How to use
Make sure to order the handler in the correct place:
```Caddyfile
{
order minify after encode
}
```
With file_server:
```
example.com {
minify
root ./test
file_server
}
```
or reverse_proxy:
```
example.com {
minify
reverse_proxy localhost:8080
}
```
limit formats (format all when not specified.):
```
example.com {
minify {
formats html css js
}
reverse_proxy
}
```
or simply:
```
example.com {
minify html css js
reverse_proxy localhost:8080
}
```
## Limitations
This module doesn't minify the original responses that have already been compressed, It just skips them.
To work around this, you may send the `Accept-Encoding: identity` request header to the upstream to tell it not to compress the response. For example:
```caddyfile
reverse_proxy localhost:8080 {
header_up Accept-Encoding identity
}
```