Giter Club home page Giter Club logo

Comments (3)

dougwilson avatar dougwilson commented on May 3, 2024

Hm, I'm not sure. Can you provide some more information? I'm just not quite sure what that is.

In general, this module is a dynamic compression module that transparently compresses your responses from your Express server. The standard way to use it is here: https://github.com/expressjs/compression#expressconnect

from compression.

cruzlutor avatar cruzlutor commented on May 3, 2024

Maybe not work by default, the .data file is a application/octet-stream mime type

from compression.

dougwilson avatar dougwilson commented on May 3, 2024

Ah, yes. The type application/octet-stream signifies binary data and typically standard compression algorithms do not compress data well that is non-repeating (and typically binary data fits in this bucket). It's definitely possible that the binary data used in your specific .data files can be compressed, though.

All you need to do to start compressing your .data files with this module is extend the filter option (example in https://github.com/expressjs/compression#filter-1).

Depending on how you are serving these files, you can change the definition to best fit that. I'm going to provide an example here which will always compress anything you serve from the /webgl/ path on your server, even if they are binary files:

var compression = require('compression')
var parseUrl = require('parseurl')

// set up your app

app.use(compression({filter: shouldCompress}))

function shouldCompress(req, res) {
  // customize this if logic to meet your needs
  if (parseUrl(req).pathname.substr(0, 7) === '/webgl/') {
    // always compress responses to the /webgl/ directory
    return true
  }

  // fallback to standard filter function
  return compression.filter(req, res)
}

from compression.

Related Issues (20)

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.