http-equiv

meta标签上的http-equiv属性与http头部信息相关,而且是响应头,因为html本质上是通过服务器响应得到的。http-equiv用于伪装 HTTP 响应头部信息

值描述
cache-control控制文档的缓存机制。允许的值如下:public:所有内容都将被缓存(客户端和代理服务器都可缓存);private:内容只缓存到私有缓存中(仅客户端可以缓存,代理服务器不可缓存);no-cache:不缓存,前提是通过服务器的缓存验证机制,如过期,内容改变等校验规则;no-store:所有内容都不会被缓存到缓存或 Internet 临时文件中
content-language响应体的语言。如zh-CN, en-US等
content-type返回内容的MIME类型
date原始服务器消息发出的时间,GMT时间格式
expires响应过期的日期和时间,GMT时间格式
last-modified请求资源的最后修改时间,GMT时间格式
location用来重定向接收方到非请求URL的位置来完成请求或标识新的资源
refresh定义间隔多久后刷新页面。单位是秒
set-cookie创建一个 cookie ,包含 cookie 名,cookie 值,过期时间
window-target用来防止别人在框架里调用自己的页面。

其他

  1. 指定字符编码
1
  <meta charset="UTF-8">
  1. IE 杀手
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  <!-- renderer适用于国产双内核浏览器 -->
  <!-- 使用Blink(Webkit) -->
  <meta name="renderer" content="webkit">
  <!-- IE兼容模式,使用ie低版本兼容 -->
  <meta name="renderer" content="ie-comp">
  <!-- IE标准模式,使用ie高版本兼容 -->
  <meta name="renderer" content="ie-stand">
  <!-- force-rendering适用于其他双内核浏览器 -->
  <meta name="force-rendering" content="webkit">
  <!-- 强化对IE的兼容性,强制IE使用最新版标准模式渲染或者使用Chrome Frame渲染 -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  1. viewport常见设置,一般适用于移动端。视口宽度设为理想宽度,禁止缩放
1
  <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
  1. meta 三剑客
1
2
3
  <meta name="description" content="Tusi博客,专注大前端技术架构与分享,关注用户体验">
  <meta name="keyword" content="Tusi博客,web前端,nodejs全栈,响应式,用户体验">
  <meta name="author" content="Tusi">
  1. UC浏览器私有meta
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
  <!-- 横屏/竖屏 -->
  <meta name="screen-orientation" content="landscape|portrait">
  <!-- 全屏 -->
  <meta name="full-screen" content="yes">
  <!-- 缩放不出滚动条 -->
  <meta name="viewport" content="uc-fitscreen=yes|no">
  <!-- 排版,fitscreen简化页面,适合阅读省流量,standard模式和标准浏览器一致 -->
  <meta name="layoutmode" content="fitscreen|standard"
  <!-- 夜间模式的启用和禁用 -->
  <meta name="nightmode" content="enable|disable"/>
  <!-- 强制图片显示 -->
  <meta name="imagemode" content="force"/>
  <!-- 强制图片显示,只作用于单图 -->
  <img src="..." show="force">
  <!-- 应用模式,默认全屏,禁止长按菜单,禁止手势,标准排版,以及强制图片显示。 -->
  <meta name="browsermode" content="application">
  1. QQ浏览器X5内核私有meta(现在微信内置浏览器的内核也是X5哦
1
2
3
4
5
6
  <!-- 横屏/竖屏 -->
  <meta name="x5-orientation" content="landscape|portrait">
  <!-- 全屏 -->
  <meta name="x5-fullscreen" content="true">
  <!-- 应用模式 -->
  <meta name="x5-page-mode" content="app">
  1. iphone适配
1
2
3
4
5
6
7
8
  <!-- "添加到主屏幕“后,全屏显示 -->
  <meta name="apple-touch-fullscreen" content="yes">
  <!-- 隐藏菜单栏和状态栏,类似于应用模式 -->
  <meta name="apple-mobile-web-app-capable" content="yes|no">
  <!-- 设置状态栏颜色,貌似只有default白色,black黑色,black-translucent灰色半透明 -->
  <meta name=”apple-mobile-web-app-status-bar-style” content=black”>
  <!-- 取消电话号码识别,防止误触拨号 -->
  <meta name="format-detection" content="telephone=no">
  1. 其他优化和适配手段
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 -->
  <meta name="HandheldFriendly" content="true">

  <!-- 微软的老式浏览器 -->
  <meta name="MobileOptimized" content="320">

  <!-- windows phone 点击无高光 -->
  <meta name="msapplication-tap-highlight" content="no">

  <!-- robots 用来告诉搜索机器人哪些页面需要被检索 -->
  <!-- index 搜索引擎抓取这个页面 -->
  <!-- noindex 搜索引擎不抓取这个页面 -->
  <!-- follow 抓取外链 -->
  <!-- nofollow 不抓取外链 -->
  <meta name="robots" content="index,follow">
  <meta name="robots" content="index,nofollow">
  <meta name="robots" content="noindex,follow">
  <meta name="robots" content="noindex,nofollow">

  <!-- referrer 控制http请求头的referer,暂时没想到什么实际应用场景 -->
  <!-- no-referrer 不发referer -->
  <!-- origin 只发送origin部分 -->
  <!-- no-referrer-when-downgrade 默认值,当目的地是先验安全的(https->https)则发送origin作为 referrer,但是当目的地是较不安全的(https->http)时则不发送referrer -->。
  <!-- origin-when-crossorigin 在同源请求下,发送完整的URL(不含查询参数),其他情况下则仅发送当前文档的origin -->
  <!-- unsafe-URL 在同源请求下,发送完整的URL(不含查询参数) -->
  <meta name="referrer" content="no-referrer">

  <!-- og: Open Graph Protocol,一种友好的配置,让自己的网站在社交网络分享中更得心应手,更多的配置可以去自行搜索 -->
  <!-- og:type 告诉SNS,我这是一个什么类型的网站 -->
  <meta property="og:type" content="article"/>
  <!-- og:title 告诉SNS,分享时告诉用户我这个网站的标题是什么,别自己瞎搞个标题 -->
  <meta property="og:title" content="Tusi博客"/>
  <meta property="og:url" content="https://blog.wbjiang.cn"/>
  <!-- og:image 缩略图 -->
  <meta property="og:image" content="/static/imgs/thumbnail.png"/>
  <meta property="og:description" content="专注于大前端技术架构与分享,关注用户体验"/>