Nginx 图像缓存的优点和缺点是什么?
谁能帮我解释一下 Nginx 缓存图像的效果吗?
目前我正在使用专用服务器。静态图像存储在一个文件夹中并用于文章。该库的大小每天增加约 500 张图像,服务器每天访问约 800k 页。每页大约有 4 张大图。
服务器磁盘位于 RAID 1 中。
我遇到 Nginx 缓存问题。 HDD 很快就满了,导致服务器停止运行。我必须重新启动 Nginx 服务才能使 Nginx 再次清除缓存。
我正在考虑从 Nginx 中删除缓存图像配置(尤其是 .jpg
),因为我认为这个配置无论如何都对服务器没有帮助。
由于静态图像存储在一个文件夹中,因此我将 ExpiresActive
应用于标头。那么我需要 Nginx 做什么呢?
从缺点来看,我看到浪费了 HDD 容量,在一次又一次读取这些图像然后写入缓存时消耗了 CPU 和 RAM 资源。
请告诉我使用 Nginx 缓存镜像有什么好处?
Could anyone please clarify for me the effect of Nginx caching image?
Currently I am using dedicated server. Static images are stored in one folder and used for articles. The library increases in size about 500 images every day, and server hits around 800k pages/day. Each page has around 4 big images.
Server disks are in RAID 1.
I'm have issues with Nginx caching. The HDD becomes full so quickly that the server stops running. I have to restart Nginx service to make Nginx clear the cache again.
I was thinking of removing the cache images config (especially .jpg
) from Nginx, because I think this config doesn't help server anyway.
Since static images are stored in one folder, I applied ExpiresActive
to header. So what do I need Nginx for?
From downside I see wasted HDD volume, spent resources of CPU and RAM while reading those images again and again then writing to cache.
Please tell me what benefits I will have by using Nginx cache image?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议不要缓存任何图像(或任何静态内容)。 Nginx 已经能够高效地从磁盘提供静态内容。
PS:我无法评论。因此,将其写为答案。谢谢。
I'd recommend not to cache any images (or any static content). Nginx is already efficient in serving static content from the disk.
PS: I can't comment. So, writing it as an answer. Thanks.