From 750d434a5592b422686ef0217ecab6cc2abcce7a Mon Sep 17 00:00:00 2001 From: Scott Gress Date: Wed, 10 Feb 2016 16:59:18 -0600 Subject: [PATCH] Fix issue with incorrect default cache config being set --- lib/hooks/http/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/hooks/http/index.js b/lib/hooks/http/index.js index 9dad748cf..996573dcc 100644 --- a/lib/hooks/http/index.js +++ b/lib/hooks/http/index.js @@ -35,11 +35,6 @@ module.exports = function(sails) { // Users' SSL cert settings end up here ssl: {}, - // HTTP cache configuration - cache: { - maxAge: config.environment === 'development' ? 1 : 31557600000 - }, - // Path static files will be served from // Uses `path.resolve()` to accept either: // • an absolute path @@ -81,6 +76,8 @@ module.exports = function(sails) { }, + // HTTP cache configuration + cache: config.environment === 'development' ? 1 : 31557600000, // Extra options to pass directly into the Express server // when it is instantiated @@ -167,6 +164,16 @@ module.exports = function(sails) { // Merge in legacy `sails.config.express` object for backwards-compat. _.defaultsDeep(sails.config.http, sails.config.express||{}); + // Warn if using incorrect cache config (this used to be a default, but was incorrect and never doc'd) + if (sails.config.cache && sails.config.cache.maxAge) { + sails.log.warn('`sails.config.cache.maxAge is deprecated; use `sails.config.http.cache` instead.'); + } + // That being said, set the default to match sails.config.http.cache in case anyone is relying on it. + // This will be removed completely in Sails 1.0! + sails.config.cache = { + maxAge: sails.config.http.cache + }; + // If no custom middleware order is specified, make sure the default one is used. // This lets you override default middleware without having to explicitly include the // "order" array in your http.js config file.