跨域和200,304和get/post的区别

304:

如果cache-control:no-chache说明强制每次请求直接发送给源服务器,而不经过本地缓存版本的校验。

如果cache-control:max-age=0有二种情况:
1、max-age>0 时 直接从游览器缓存中 提取
2、max-age<=0 时 向server 发送http 请求确认 ,该资源是否有修改有的话 返回200 ,无的话 返回304.

防止304:
1\在请求地址上加一个时间戳或者随机数,
2\前端界面禁止缓存 例如: respone中设置一个属性 cache-control:no-store 禁止缓存。

跨域:

1\ websocket
2\ -- disable-web-secrity
3\ nginx
4\ ifram
5\ postmessage

window.οnlοad=function(){
window.frames[0].postMessage(‘getcolor’,‘http://lslib.com’);
}

6\ 利用jsonp 利用script标签中设置src="" ,不太用,因为支持get方法
7\ node express

get和post的区别

  • get在url中传参,不太安全,是有长度限制,post在requst body中传参,没有限制,安全.
  • get只能进行url编码,而post可以多种.
  • get会主动cache,post需要手动设置.
  • get产生一个tcp数据包,post产生2个tcp数据包.

对于GET方式的请求,浏览器会把http header和data一并发送出去,服务器响应200(返回数据);
而对于POST,浏览器先发送header,服务器响应100 continue,浏览器再发送data,服务器响应200 ok(返回数据)

  • get 响应速度更快

你可能感兴趣的:(跨域和200,304和get/post的区别)