HTML 不缓存 & meta og

HTML 设置不缓存页面内容

<meta http-equiv="Expires" content="-1">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">

HTML META og

og 是一种新的 HTTP 头部标记,即Open Graph Protocol

The Open Graph Protocol enables any web page to become a rich object in a social graph.

即这种协议可以让网页成为一个“富媒体对象”。
用了 meta property=og 标签,就是你同意了网页内容可以被其他社会化网站引用等,目前这种协议被 SNS 网站如 Fackbook,renren,whatsapp 采用。
SNS 已经成为网络上的一大热门应用,优质的内容通过分享在好友间迅速传播。为了提高站外内容的传播效率,2010 年 F8 会议上 Fackbook 公布了一套开放内容协议(Open Graph Protocol),任何网页只要遵守该协议,SNS 就能从页面上提取最有效的信息并呈现给用户。

<meta property="og:title" content="hello world">
<meta property="og:type" content="website">
<meta property="og:url" content="https://neveryu.github.io/">
<meta property="og:image" content="https://neveryu.github.io/avatar/avatar.png">
<meta property="og:description" content="thank you follow me">

HTML meta 标签

所有的浏览器都支持 meta 标签,用于提供页面相关信息,信息都是以名(http-equiv 和 name 标示) / 值(content标示)对的形式实现。

属性 content,用于定义 http-equiv(定义 http 头部信息,服务器向浏览器提供的信息)和 name(指定网页信息的相关的名称)相关的信息。

http-equiv 属性

http-equiv 属性(一些保护网站措施)

http-equiv 顾名思义,相当于 http 的文件头作用,它可以向浏览器传回一些有用的信息,以帮助正确和精准地显示网页内容,与之对应的属性值为 content,content中的内容其实就是各个参数的变量值。

属性作用示例
http-equivcontent-type设置页面字符集<meta http-equiv="content-Type" content="text/html; charset=UTF-8"> // html5 页面的做法是直接使用 <meta charset="UTF-8">
Set-Cookie如果cookie过期,则自动删除本地cookie<meta http-equiv="Set-Cookie" content="cookievalue=xxx;expires=Friday,12-Jan-2001 18:18:18 GMT; path=/"> // 注意:必须使用GMT的时间格式
Window-target强制页面在当前窗口以独立页面实现<meta http-equiv="Window=target" content="_top"> // 用来防止别人在框架里调用自己的页面,可以防止网页被别人作为一个Frame调用。
expires设置页面的过期时间<meta http-equiv="expires" content="Wed,20 Jun 2007 22:33:00 GMT">
refresh自动刷新到新页面<meta http-equiv="Refresh" content="2;URL=http://www.baidu.com"> //2代表页面停留多长时间后跳转到后面的网址上
pragma禁止浏览器从本地调用缓存<meta http-equiv="Pragma" content="no-chach">
page_enter,page_exit设定进入页面和退出页面的效果<meta http-equiv="Page-Exit" content="revealTrans(duration=1.0,transtion=12)"
cache-control清除缓存<meta http-equiv="cache-control" content="no-cache">

name 属性(对SEO的作用比较大)

name 属性(对SEO的作用比较大)

name 属性主要用于描述网页,与之对应的属性值为 conent,content 中的内容主要是便于搜索引擎机器人查找信息和分类信息用的。

属性作用示例解释
namaauthor指定页面的所有者<meta name="author" content="Never Yu">
description页面描述,用于搜索引擎收录<meta name="description" content="我的博客">
keywords页面关键词,用于被搜索引擎收录<meta name="keywords" content="JavaScript HTML CSS NodeJS GO">
generator用于说明网站制作生成工具<meta name="generator" content="Hexo">
revised网页文档的修改时间<meta name="revised" content="2017/04/14">
viewport用于控制页面缩放<meta name=”viewport” content=”width=240, height=320, user-scalable=yes, initial-scale=2.5, maximum-scale=5.0, minimun-scale=1.0”> //width指定页面的可视宽度, 像素值或device-width, initial-scale设置页面初始化时的缩放比例,user-scalable指定是否可以缩放可视区域, maximum-scale, minimun-scale页面最大最小缩放比例。 如果想要页面在不同的设备都按照页面的设计尺寸缩放(那些宽度固定的网站)就不要使用viewport属性
copyright网页版权信息<meta name="copyright" content="Copyright 2017 All">
renderer使用哪种模式显示网页`
robotsrobots(机器人向导)说明:robots用来告诉搜索机器人哪些页面需要索引,哪些页面不需要索引<meta name="tobots" content="index,follow" // content的参数有 all,none,index,noindex,follow,nofollow。默认是all
format-detection(忽略电话号码和邮箱)说明:忽略页面中的数字识别为电话号码<meta name="format-detection" content="telephone=no"> // 忽略页面中的数字识别为电话号码 <meta name="format-detection" content="email=no"> //忽略页面中的邮箱格式为邮箱
HandheldFriendly针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓<meta name="HandheldFriendly" content="true">
screen-orientationuc强制竖屏<meta name="screen-orientation" content="portrait">
x5-orientationQQ强制竖屏<meta name="x5-orientation" content="portrait">
full-screenuc强制全屏<meta name="full-screen" content="yes">
x5-fullscreenQQ强制全屏<meta name="x5-fullscreen" content="true">
browsermodeuc应用模式<meta name="browsermode" content="application">
x5-page-modeQQ 应用模式<meta name="x5-page-mode" content="app">

—————————(正文完)————————————
一个前端的学习交流群,想进来面基的,可以点击这个logoVue学习交流,或者手动search群号:685486827



写在最后: 约定优于配置——-软件开发的简约原则.


——————————– (完)————————————–

我的:
个人网站: https://neveryu.github.io/neveryu/
Github: https://github.com/Neveryu
新浪微博: https://weibo.com/Neveryu

微信


更多学习资源请关注我的新浪微博….

width="100%" height="500" class="share_self" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=550&fansRow=1&ptype=1&speed=0&skin=8&isTitle=1&noborder=1&isWeibo=1&isFans=0&uid=5346488237&verifier=d529ff3a&dpc=1">


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值