4

I'd like to pre-compress my static assets (excluding images) and serve them.

To serve the public folder, I have:

app.use(express.static('path/to/public/')); 

I believe express.compress() compresses on-the-fly, which seems like an unnecessary burden on the server CPU for static assets.

What's the canonical way to achieve this?

1
  • Bonus points for having it uncompress on the fly for clients that don't support compression, rather than requiring the uncompressed version to be kept on the server as well. Commented Jan 27, 2015 at 23:06

1 Answer 1

3

The connect-gzip-static module seems to do this. I haven't tested it yet.

It doesn't support dynamically decompressing assets where the client doesn't support compression, which means you need to keep an uncompressed copy of the asset on the server as well, and you have to make sure they are in sync.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.