Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextjs 的 Image 如何关闭本地缓存 #55

Closed
Tracked by #38
521xueweihan opened this issue Oct 4, 2022 · 4 comments
Closed
Tracked by #38

Nextjs 的 Image 如何关闭本地缓存 #55

521xueweihan opened this issue Oct 4, 2022 · 4 comments

Comments

@521xueweihan
Copy link
Member

521xueweihan commented Oct 4, 2022

Nextjs 的 image 会缓存 src 地址的图片,但是这样

  1. 不好控制 nginx 的访问频率限制
  2. 服务器压力有点大

我看了 next 的文档没找到怎么关闭这个缓存。😢

@521xueweihan 521xueweihan changed the title Nextjs 的 Image Nextjs 的 Image 如何关闭本地缓存 Oct 4, 2022
@521xueweihan
Copy link
Member Author

521xueweihan commented Oct 6, 2022

目前我采用 img 标签,替换 Nextjs Image 组件,实现不经过 nextjs 缓存,直接访问图床地址。

不知道是否为最优方案

@zhangzhonghe
Copy link
Collaborator

不是很明白。

如果图片会被缓存到浏览器,不是可以减轻服务器压力吗?请求的次数降低了呀。

@zhangzhonghe
Copy link
Collaborator

有试过这个配置项吗?

@521xueweihan
Copy link
Member Author

521xueweihan commented Oct 12, 2022

@zhangzhonghe 目前咱们网站的图片,都是放在图床/CDN(upyun)

如果是用 next.js 的 Image 组件,会拉取 图床的图片到我们自己的服务器,然后图片的请求地址就转接到咱们自己的服务器了。

从而增加了 HelloGitHub 网站所在服务器的负载,而且图片比较占带宽。

有试过这个配置项吗? 这个配置应该是设置图片缓存失效的时间,感觉用处不大。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants