This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In #1929, we removed mobile-wiki's reliance on an internal DFS bucket to store front-end assets. Unfortunately, this also removed support for brotli compression (implemented via nginx servers on the DFS nodes). This patch restores support for brotli via ember-cli-deploy and ember-cli-deploy-compress plugins to generate compressed assets during the build step and serve them via express-static-gzip if the client supports them. In order to actually enable brotli support, we will need to update our Fastly VCL as well to ensure that we normalize the Accept-Encoding header to 'br' if the client supports brotli. If we're not careful, this will invalidate all mobile-wiki asset URLs, causing clients requesting older versions of asset URLs embedded in cached HTML to be served a 404 from the current deployment and fail. To fully remedy this, we may need to re-introduce semi-persistent asset storage in either s3 or GCS, but for now, let's just change the asset URL paths so that we can update the VCL logic only for the new paths, without invalidating the old URLs.
- Loading branch information
1 parent
f72c339
commit 53052a8
Showing
10 changed files
with
299 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-env node */ | ||
|
||
'use strict'; | ||
|
||
module.exports = function (deployTarget) { | ||
const ENV = { | ||
build: { | ||
outputPath: 'dist/mobile-wiki', | ||
}, | ||
// include other plugin configuration that applies to all deploy targets here | ||
compress: { | ||
compression: ['gzip', 'brotli'], | ||
keep: true, | ||
}, | ||
}; | ||
|
||
if (deployTarget === 'development') { | ||
ENV.build.environment = 'development'; | ||
// configure other plugins for development deploy target here | ||
} | ||
|
||
if (deployTarget === 'production') { | ||
ENV.build.environment = 'production'; | ||
// configure other plugins for production deploy target here | ||
} | ||
|
||
// Note: if you need to build some configuration asynchronously, you can return | ||
// a promise that resolves with the ENV object instead of returning the | ||
// ENV object synchronously. | ||
return ENV; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
const express = require('express'); | ||
const expressStaticGzip = require('express-static-gzip'); | ||
const config = require('../config/fastboot-server'); | ||
|
||
module.exports = express.static(config.distPath, { | ||
setHeaders: (res) => { | ||
res.set('Cache-Control', `s-maxage=${config.staticAssetsTTL}`); | ||
res.set('X-Pass-Cache-Control', `public, max-age=${config.staticAssetsTTL}`); | ||
res.set('Vary', 'accept-encoding'); | ||
module.exports = expressStaticGzip(config.distPath, { | ||
enableBrotli: true, | ||
serveStatic: { | ||
setHeaders: (res) => { | ||
res.set('Cache-Control', `s-maxage=${config.staticAssetsTTL}`); | ||
res.set('X-Pass-Cache-Control', `public, max-age=${config.staticAssetsTTL}`); | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.