Explorar o código

optimize cache settings for express

Yuki Takei %!s(int64=8) %!d(string=hai) anos
pai
achega
eeaa29f5dd
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  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());