FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 555   



Following NodeJS + Express code shows you how to set max-age for static content.
Let's say you have static content in folders /public/images, /public/css, /public/js in the following code i am iterating on those folders and setting max-age for one day.

var express = require('express');
var app = express();

var oneDay = 86400000;
var staticResourceFolders = ['images', 'css', 'js'];

staticResourceFolders.forEach(function(staticResourceFolder) {
  app.use('/' + staticResourceFolder, express.static(__dirname + '/public/' + staticResourceFolder, {
    maxAge: oneDay
  }));
});



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News