Node Express 中的缓存:如何将视图列入白名单/黑名单?

发布于 2024-11-27 10:45:19 字数 146 浏览 0 评论 0原文

Express 有一个内置的缓存机制,通过 app.enable('view cache')设置。但是,如何区分应该缓存的视图和应该始终新鲜提供的视图?

Express has a builtin cache mechanism, set up with app.enable('view cache'). But how do you discriminate between views which should be cached and views which should always be served fresh?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅语花开 2024-12-04 10:45:19

我不知道细节,但我认为它缓存了所有内容。我的意思是,它将所有视图放入内存中。我认为您不应该区分视图,而应该缓存所有视图。如果你不想要这个,你可以通过将它们放入内存或 Redis 或其他东西中来自己进行缓存。

但我建议您在 Github 上填写问题。我打赌 TJ 会在 Github 上对此做出回应,但不会阅读本文,因为在 Github 上他会收到电子邮件,而在 Stackoverflow 上他不会。

I don't know the details, but I think it caches everything. What I mean is that it puts all views inside memory. I don't think you should discriminate between views and should just cache all views. If you don't want this, you could just do the caching yourself by putting them in memory or Redis or something.

But I would advice you to fill issue at Github. I bet TJ will response to that at Github, but does not read this, because at Github he gets email and Stackoverflow he does not.

顾铮苏瑾 2024-12-04 10:45:19

不应该缓存可变的视图;仅应缓存静态视图。由您的应用程序来确定哪个是哪个。

Views which are mutable should not be cached; only views which are static should be cached. It's up to your application to determine which is which.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文