javascript - gzip and minify server route response in meteor and iron-router -


i used meteor , iron-router , set many server route return html node.js response object.

now want minify , enable gzip in response. how this?

this route code:

router.route('/', function () {     var res = this.response;     var html =  "<!doctype html>\n" +         "<html>\n" +         "    <head>\n" +         "    </head>\n" +         "    <body>\n" +         "        test\n" +         "    </body>\n" +         "</html>";     res.end(html); }, { where: 'server' }); 

this page result:

<!doctype html> <html>     <head>     </head>     <body>         test     </body> </html> 

i want minified version below:

<!doctype html><html><head></head><body>test</body></html> 

i deploy test project in url:

http://gzipminify.meteor.com/

and can test gzip support this tools.

meteor gzips , minifies (in production mode) app.

just not cause confusion main app file root file available @ xxx.meteor.com not impacted (the 1 containing html similar index.html).

also index.html like file bare 1 containing references js & css files. actual js file containing app's html indeed gzipped too.

the rest of static assets (css, js, images, etc) gzipd.

in production mode css & js minified.

your site @ gzipminify.meteor.com has no static assets nor css.

on other hand

is web page compressed : yes http://test.meteor.com/5166d4fcc07e1605cbe979ef217942271d8badac.js

is web page compressed: no (http://test.meteor.com)

for custom server side rendered route iron router can gzip files including middleware router.onbeforeaction instead of app.use compression middleware of choice (nodejs).


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -