Skip to content

Commit

Permalink
feat: configure gzip compression (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffroy Empain committed Mar 9, 2021
1 parent 09621ea commit bc5e3ff
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/caddy/config/sites/generate-site-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ const cacheHandler = {
},
};

// https://caddyserver.com/docs/json/apps/http/servers/routes/handle/encode/encodings/gzip/
// https://caddy.community/t/gzip-headers-when-using-encode-handler/11781
const gzipHandler = {
handler: 'encode',
encodings: {
gzip: {},
},
};

function getPrimaryRoute(site: Site, branch: Branch) {
const branchDirInCaddy = getBranchDirInCaddy(site._id, branch._id);

Expand All @@ -114,6 +123,7 @@ function getPrimaryRoute(site: Site, branch: Branch) {
uri: '{http.matchers.file.relative}',
},
cacheHandler,
gzipHandler,
fileHandler,
],
};
Expand All @@ -122,6 +132,7 @@ function getPrimaryRoute(site: Site, branch: Branch) {
return {
handle: [
cacheHandler,
gzipHandler,
fileHandler,
],
};
Expand Down

0 comments on commit bc5e3ff

Please sign in to comment.