简体   繁体   English

将mod_pagespeed与本机node.js服务器一起使用

[英]Using mod_pagespeed with native node.js server

I've been looking for a solution to optimize images for better performance. 我一直在寻找一种优化图像的解决方案,以获得更好的性能。

After trying some solutions (like sharp and imagemin , which resulted in never smaller, sometimes bigger files), I am now looking to experiment with Google's pagespeed. 在尝试了一些解决方案(比如sharpimagemin ,这导致了从不会更小,有时更大的文件)之后,我现在正在尝试使用Google的pagespeed。 Unfortunately, pagespeed seems to only support Apache and Nginx, which I would not like to add to my stack just for image optimization (also, I would prefer making the optimization once on upload, and not on server request, even if cached). 不幸的是,pagespeed似乎只支持Apache和Nginx,我不想仅仅为了图像优化而添加到我的堆栈中(同样,我希望在上传时进行一次优化,而不是在服务器请求上,即使是缓存)。

I will be very grateful for any information that might help me implement this in native node.js, and for any other (working!) image optimization recommendations. 我将非常感谢任何可能帮助我在本地node.js中实现此功能的信息, 以及任何其他(工作!)图像优化建议。

I suggest you only use node for dynamic content (eg: your application server logic). 我建议你只使用node作为动态内容(例如:你的应用服务器逻辑)。

For static content, such as images, stylesheets and others... just serve them with a regular web server like nginx. 对于静态内容,例如图像,样式表和其他内容......只需使用像nginx这样的常规Web服务器即可。 There you can use ngx_pagespeed. 在那里你可以使用ngx_pagespeed。

Try npm module lwip . 试试npm模块lwip

It's a standalone library(re-built when installing) and no runtime dependencies. 它是一个独立的库(安装时重新构建),没有运行时依赖项。

I use its resize and scale operations to create thumb images in my file service project . 我使用它的调整大小缩放操作在我的文件服务项目中创建拇指图像。

Check if this is what you need. 检查这是否是您所需要的。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM