Search Unity

How serve gzip in nodejs / express

Discussion in 'Web' started by Onsterion, Jul 11, 2016.

  1. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    I tried for hours installing plugins and testing configurations but no case i continue receiving "You can remove this delay if you configure your web server to host files using gzip compression."

    Site link: http://onsterion.com/

    Nodejs app code:

    Code (CSharp):
    1. var staticGzip = require('http-static-gzip-regexp');
    2. var compress = require('compression');
    3. var express = require('express');
    4. var app = express();
    5.  
    6. //Add the middleware express way:
    7. app.use(staticGzip(/(\Release\.datagz|\Release\.jsgz|\Release\.memgz)$/));
    8.  
    9. //Add dynamic compression if you don't handle all files static
    10. app.use(compress());
    11.  
    12. //Add a static web handler you prefer
    13. app.use(express.static('statics'));
    14.  
    15. var port = 3000;
    16.  
    17. app.listen(port, function () {
    18.     console.log("App listening on port: " + port);
    19. });
    Any suggestion for setup (node js / express) for serve the compression files?


    Sorry for my english,
    Greetings.-
     
    Last edited: Jul 11, 2016