Why is .js.gz file not being served?
See original GitHub issueI gzipped my app.js
to app.js.gz
and then ran http-server -g
, as specified in the readme of this website.
But my browser still receives the .js file, not the .js.gz file, as you can see in the screenshot. Is this is a bug?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:22 (4 by maintainers)
Top Results From Across the Web
Gzipped javascript not being served properly - Stack Overflow
I have encountered problems with some browsers (notably Safari) not dealing appropriately when the file name extension was ".gz".
Read more >(html gzip) files seem to not be served - WordPress.org
When the “Pre-compression of cached pages. Needs to be disabled if the decoding fails in the web browser” option is active, you *normally* ......
Read more >Point next export .html files at .js.gz files : r/nextjs - Reddit
I'm serving a nextjs app over CDN(no server) and I'm generating gzipped js files with ` compression-webpack-plugin`. But the .js.gz files ...
Read more >Serve Pre-Compressed CSS/JS Files - WP Rocket
But the pre-compressed files will not be served automatically due to the possibility of server conflicts. If you want to take advantage of...
Read more >How to use a gzip javascript file in a webapp running under ...
if not how to send a gzip javascript file to browser? any help would be ... your gzip'd CSS file and serves it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@thescientist13 as I stated above, it worked if you generated your own
gz
files. The issue I was having was that if I enabled/passed a flag saying “turn gzip on”, I was expecting the server to do the gzip’ing on the fly. I’m fine with generating the files manually (now that I know that’s what I was supposed to do). It was just frustrating at the time since I wasted time thinking it was user error. Really what the--gzip
flag does, is say “if a gz version of a file exists, I’ll use that instead” - not “I’ll now gzip and serve specified file types”.I’m running
0.10.0
, looks like the gzip PR’s in there, but I’m still not seeing gzipped content come through. I’m runninghttp-server ./build --gzip -o -p 8080
.After reading through
ecstatic
’s docs, https://www.npmjs.com/package/ecstatic#optsgzip led me to what @RichardJECooke tried (to manually create a.gz
file). After doing so, I’m seeing that file served.The confusion seems to come from the fact that most servers that have a “simple setup” (and gzip is one of the available options), the server will do the work of gzipping for you (which is what I expected). This should really be called out in the docs to lessen confusion.
Possible solutions to anyone that come across this issue:
ecstatic
folks to update themiddleware
function to utilize the built inzlib
module so files get automagically served up gzipped.CompressionPlugin
to generate the.gz
files at build time with a configuration like this