Skip to content

Commit

Permalink
Fix issue with incorrect default cache config being set
Browse files Browse the repository at this point in the history
  • Loading branch information
sgress454 committed Feb 10, 2016
1 parent 89be44e commit 750d434
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/hooks/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 750d434

Please sign in to comment.