GithubHelp home page GithubHelp logo

imperugo / nodejs-sample Goto Github PK

View Code? Open in Web Editor NEW
47.0 6.0 17.0 720 KB

Some NodeJS Samples

Home Page: http://tostring.it/categories/#nodejs

JavaScript 2.01% CSS 96.09% Python 1.84% Shell 0.06%

nodejs-sample's Introduction

A collection of node js samples

The example in this repository comes from the Ugo Lattanzi's blog, so you can find the explanation here.

Folder structure

Each example has a folder and, inside it, there is a Readme.mdfile with the link of the blog post.

List of samples

  • How to configure a cluster with NodeJS (blog post here);

  • Advanced logging with NodeJs (blog post here);

##Questions? Write me here, contact me via email (available on my Github profile) or follow me on Twitter here.

nodejs-sample's People

Contributors

imperugo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nodejs-sample's Issues

maxAge is incorrect in express-configuration

In the file express-configuration/index.js the maxAge is logged as one day but in reality is set to one year.

console.log("Setting 'Public' folder with maxAge: 1 Day.");
    var publicFolder = path.dirname(module.parent.filename)  + "/public";
    var oneYear = 31557600000;
    app.use(express.static(publicFolder, { maxAge: oneYear }));

Since setting public cache to one year is the maximum recommended, I suggest changing the log to the following:

console.log("Setting 'Public' folder with maxAge: 1 Year.");
    var publicFolder = path.dirname(module.parent.filename)  + "/public";
    var oneYear = 31557600000;
    app.use(express.static(publicFolder, { maxAge: oneYear }));

The other option is to use 86400000 milliseconds such as the following:

console.log("Setting 'Public' folder with maxAge: 1 Day.");
    var publicFolder = path.dirname(module.parent.filename)  + "/public";
    var oneDay = 86400000;
    app.use(express.static(publicFolder, { maxAge: oneDay }));

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.