Merge pull request #6461 from terinjokes/resource-hints

Add Preload link headers for browsers and CDNs
This commit is contained in:
Hannah Wolfe 2016-04-28 09:51:14 +01:00
commit 8808674bbd
3 changed files with 12 additions and 1 deletions

View File

@ -212,7 +212,8 @@ ConfigManager.prototype.set = function (config) {
},
deprecatedItems: ['updateCheck', 'mail.fromaddress'],
// create a hash for cache busting assets
assetHash: assetHash
assetHash: assetHash,
preloadHeaders: this._config.preloadHeaders || false
});
// Also pass config object to

View File

@ -25,6 +25,7 @@ var bodyParser = require('body-parser'),
themeHandler = require('./theme-handler'),
uncapitalise = require('./uncapitalise'),
cors = require('./cors'),
netjet = require('netjet'),
ClientPasswordStrategy = require('passport-oauth2-client-password').Strategy,
BearerStrategy = require('passport-http-bearer').Strategy,
@ -70,6 +71,14 @@ setupMiddleware = function setupMiddleware(blogApp, adminApp) {
}
}
// Preload link headers
if (config.preloadHeaders) {
blogApp.use(netjet({
cache: {
max: config.preloadHeaders
}
}));
}
// Favicon
blogApp.use(serveSharedFile('favicon.ico', 'image/x-icon', utils.ONE_DAY_S));

View File

@ -53,6 +53,7 @@
"moment": "2.13.0",
"morgan": "1.7.0",
"multer": "1.1.0",
"netjet": "1.1.0",
"node-uuid": "1.4.7",
"nodemailer": "0.7.1",
"oauth2orize": "1.2.2",