If-None-Match 有效时 304 Not Modified [英] 304 Not Modified When If-None-Match is valid

查看:27
本文介绍了If-None-Match 有效时 304 Not Modified的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在优化一个 Express JSON API 以供 iOS &Android 应用程序,并且当应用程序在 If-None-Match 标头中指定 etag 时,似乎无法让 Express 以正确的 304 标头响应.

I am optimizing an Express JSON API for consumption by iOS & Android Apps and do not seem to be able to get Express to respond with the correct 304 header when the Apps specify an etag within the If-None-Match header.

我不需要设置 Etag 生成,因为 Express 已经提供了这些;但是,当应用程序在第二个请求中再次指定该 etag 时;Express 的响应仍然是 200 的数据,正如您在 Postman 中的测试中看到的那样:

I needn't setup Etag generation as Express was already providing those; however when the Apps specify that etag again in a second request; Express' response is still a 200 with the data, as you can see in my tests in Postman:

如何启用此功能?

更新:iOS 开发人员从 Express 服务器看到正确的 304 Not Modified 响应,但我不明白为什么我在 Postman 中没有看到它们 - Postman 是否支持此类操作?p>

Update: The iOS dev is seeing the correct 304 Not Modified responses from the Express server but I don't understand why I am not seeing them within Postman - Does Postman support such actions?

推荐答案

我今天偶然发现这个,你需要禁用 Postman 默认发送 Cache-Controlnone.为此,只需将设置将 Send no-cache header 更改为 No.

I just stumble across this today, you need to disable Postman default behaviour of sending Cache-Control as none. To do this just go to settings change Send no-cache header to No.

这篇关于If-None-Match 有效时 304 Not Modified的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆