Comments (11)
Hmm, I don't think this module works with SPDY push, though I also think no Express middleware does, either (middleware that alters the response). I'm not too familiar with SPDY push, though.
Would you be willing to post an example or even work on a PR to add this :)?
from compression.
I could try, but I might need some pointers. Like which parts of the code to focus on. Should also figure out first how exactly we want this to work.
My current idea is something like this:
var compress = require('compression');
var file_name = 'file.js';
var file = fs.readFileSync(file);
var compressed = compress(file_name, file);
...
var stream = res.push('/' + file_name, compressed.headers, pushHandler);
compressed.data.pipe(stream);
What do you think?
from compression.
That looks like a different module; this module is only an Express middleware.
from compression.
But I would like to reuse a lot of what compression
does, like determine, if the file should be compressed at all, and what headers to set based on that. Maybe if it's like this?:
var compresser = require('compression').compresser;
var compressed = compresser(file_name, file);
from compression.
Still no; if you extract that stuff as another generic module, we can simply use your lower-level module. The only interface this module will have an an Express middleware interface.
from compression.
So you want me to make something, that compression
itself will be based on? Wow, that's a big request, I'm still a newbie to this, not feeling very confident.
It's a bit weird, that currently we can't conveniently use compression in a push stream. Makes the whole thing kind of pointless (server pushes). Or so it feels.
from compression.
Right, though I did intend to do this eventually, if you don't mind waiting, and are hesitant to do it :) When I get to a computer, I do believe there may be a way to at least temporarily hack an Express middleware to manipulate a stream, though would need to know how to use SPDY push if you can provide an example.
I think you would find that implementing that extra export as a non-hack would mean rewriting the internals of this module anyway :)
from compression.
It's a bit weird, that currently we can't conveniently use compression in a push stream. Makes the whole thing kind of pointless (server pushes). Or so it feels.
I agree, but have no experience using them, so have no idea how to go about changing this or even how to make a server that does push and understand how to make a request to said server to see the result of the push, if you can teach me?
from compression.
Currently for client side testing I'm just using the latest Firefox and Chrome, and their DevTools (ctrl+shift+i). (Can disable caching while DevTools are out.)
My current server code for push is probably pretty embarrassing, but here it is commented out:
https://github.com/hdf/clusters/blob/master/server/index.js#L111
The relevant bit is this:
function pushIt(file) {
var s = res.push('/static/' + file, mime(file), pushHandler);
var bufferStream = new stream.Transform();
bufferStream.push(push_cache[file]);
bufferStream.end();
bufferStream.pipe(s);
}
push_cache[file]
is a Buffer object.
Another idea: Is it possible, to somehow "virtually" trigger compression
, and feed what it gives to that push function and stream?
from compression.
Another idea: Is it possible, to somehow "virtually" trigger compression , and feed what it gives to that push function and stream?
That sounds like the "hack" I was thinking about, yes.
from compression.
OK, I have solved this for my self, and it is now clear, that this is not an express compression issue. It is best, if files that should be pushed are cached in a compressed state. And that is really contrary to how this module works.
from compression.
Related Issues (20)
- Setting Vary header although caching is disabled HOT 1
- "drain" event listener leak when using res.once("drain"); can't use res.removeListener("drain") HOT 3
- compresssion doesn't work ,the vue.txt is 2m HOT 2
- Content-Type: application/json; charset=utf-8 No effect HOT 2
- Question: Why this middleware HOT 2
- Corrupted compressed .js-files for Mac OS / Safari -clients HOT 11
- Is compression working when node server is running on a container? HOT 2
- middleware fails when the request has more than 1 values for accept-encoding header HOT 2
- Is compression result cached? HOT 1
- change Transfer-encoding HOT 1
- Why does the data size increase after compression HOT 1
- Force size to be a minimum... HOT 2
- Chunked encoding is broken after using this middleware HOT 1
- Using a current debug version HOT 1
- Deflate backwards HOT 7
- Compression instrumentation (before/after compression hooks) HOT 2
- Angular Not Compressing? HOT 2
- compression not working json payload HOT 6
- Crash when compressing characters like ū HOT 1
- Express returns a non-compliant HTTP/206 response when gzip is enabled HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compression.