Browse Source

optimize cache settings for express

Yuki Takei 8 years ago
parent
commit
eeaa29f5dd
1 changed files with 3 additions and 2 deletions
  1. 3 2
      lib/crowi/express-init.js

+ 3 - 2
lib/crowi/express-init.js

@@ -80,13 +80,14 @@ module.exports = function(crowi, app) {
   });
 
   app.set('port', crowi.port);
-  app.use(express.static(crowi.publicDir));
+  const staticOption = (crowi.node_env === 'production') ? {maxAge:'30d'} : {};
+  app.use(express.static(crowi.publicDir, staticOption));
   app.engine('html', cons.swig);
   app.use(webpackAssets(
     path.join(crowi.publicDir, 'js/webpack-assets.json'),
     { devMode: (crowi.node_env === 'development') })
   );
-  app.set('view cache', false);
+  // app.set('view cache', false);  // Default: true in production, otherwise undefined. -- 2017.07.04 Yuki Takei
   app.set('view engine', 'html');
   app.set('views', crowi.viewsDir);
   app.use(methodOverride());