我应该在哪里设置 HTTP 标头,例如 Expires?

发布于 2024-08-20 01:26:40 字数 228 浏览 1 评论 0原文

我想在带有 nginx 的 Phusion Passenger 上使用 Sinatra 部署一个应用程序。如果我想在静态内容(例如样式表)上设置 Expires 标头,那么似乎可以在三个地方完成此操作。

  1. 在我的 Sinatra 应用程序中,使用 API
  2. 和 Rack 中间件
  3. 在我的部署的服务器配置中

以下哪种方法是设置 HTTP 标头的最佳位置?

I want to deploy an app using Sinatra on Phusion Passenger w/ nginx. If I want to set the Expires header on my static content - stylesheets, say - there are appear to be three places where I could accomplish this.

  1. In my Sinatra app, using the API
  2. With Rack middleware
  3. In the server config for my deployment

Which of these methods is the best place for setting HTTP headers?

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

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

发布评论

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

评论(1

内心荒芜 2024-08-27 01:26:40

经过交谈并回答这个问题并看到上面的评论,我想我已经找到了我自己问题的答案。

nginx 的全部意义实际上是删除了前两个选项。

这就引出了选项#3。这是设置所有其他内容配置的地方,例如 gzip 压缩。

After talking though and answering this question and seeing the comment above, I think I have figured out the answer to my own question.

The whole point of nginx actually removes the first two options.

That leads to Option #3. This is where all the other content config is set, such as gzip compression.

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