HTTP中,什么是"X-" Prefix header?

例如 github API 的response headers有很多X前缀的头部:

查一下MDN文档:

Custom proprietary headers have historically been used with an X- prefix, but this convention was deprecated in June 2012 because of the inconveniences it caused when nonstandard fields became standard in RFC 6648; others are listed in an IANA registry, whose original content was defined in RFC 4229. IANA also maintains a registry of proposed new HTTP headers.
原来是自定义头部。但是上面文档说,已经deprecated,过时了。

作用

和HTTP headers一样,都是提供额外的信息。

Their main purpose is for providing additional information

RFC表明X前缀的自定义头已经过时了,代替解决方案是什么?

根据keycdn,推荐继续保留:

Although the recommendation to use X- has been deprecated, it doesn’t mean that it is no longer supported. In fact, there are still many scenarios where X- continues to be used.

根据stackoverflow,推荐继续保留:

Just as there are many kids that will never end up as professional athletes, many custom headers will never end up as standards. I'm inclined to keep the "X-" on those
If you're using custom HTTP Headers (as a sometimes-appropriate alternative to cookies) within your app to pass data to/from your server, and these headers are, explicitly, NOT intended ever to be used outside the context of your application, name-spacing them with an "X-" or "X-FOO-" prefix is a reasonable, and common, convention.

总结

虽然RFC已经不推荐使用带X前缀的http 头部,但是不推荐不代表禁止。根据stackoverflow和google一些资料,推荐继续使用这样的自定义头部,有时候会提供极大的便利。经过本人观察,很多网站还在使用带X前缀的HTTP头部。

最新文章

  1. WPF模糊效果(BlurEffect)
  2. ButterKnife基本使用
  3. LeetCode() Largest Number
  4. 常用COBOL函数
  5. sql server 查询和Kill死锁进程
  6. 【转】Linux 文件夹文件创建与删除
  7. BI先特技软件 Analyzer安装时的部分问题
  8. nyist 47 过河问题
  9. Python内部类型
  10. python 二分法查找
  11. java_jdbc_batch处理_主键id获取
  12. JS的词法作用域
  13. 【三支火把】---队列和栈的C程序实现
  14. WWDC2014之iOS使用动态库
  15. gtk+blade+anjuta 的简单实例
  16. Cocos-2dx-Lua中使用Luaj的完整示例(转)
  17. 1.2为什么需要public static void main(String[] args)这个方法
  18. Dapper批量更新
  19. vue v-show绑定
  20. 如何用两块硬盘做磁盘阵列的教程Raid 1

热门文章

  1. selenium规避网站监测
  2. Redis事务与可分布式锁
  3. Docker最全教程——从理论到实战(十七)
  4. 使用vim打开文件的16进制形式,编辑和全文替换
  5. webpack 代理问题
  6. canvas转盘转动?
  7. jsonp 完成跨域请求注意事项
  8. Sulley安装手记
  9. 在线教育厮杀惨烈,51Talk一家独大之后,却仍是持续亏损?
  10. mysql的优化(经典必看)