第086讲 http协议深度剖析③-http响应详解(禁用缓存设置)

image

Refresh :网页延时跳转

<?php
    //header("Refresh:3;url=http://www.baidu.com");
    header("Refresh:3;url=http://localhost/083.php");
?>

抓包数据:抓的是http://localhost/086_refresh.php

Request URL:http://localhost/086_refresh.php
Request Method:GET
Status Code:200 OK (from disk cache)
Remote Address:[::1]:80
Response Headers
Content-Length:0
Content-Type:text/html
Date:Fri, 14 Apr 2017 04:29:36 GMT
Refresh:3;url=http://localhost/083.php
Server:Apache/2.4.10 (Win32) OpenSSL/0.9.8zb mod_fcgid/2.3.9
X-Powered-By:PHP/5.4.33
Request Headers
Provisional headers are shown
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

跳转到页面抓包http://localhost/083.php

Request URL:http://localhost/083.php
Request Method:GET
Status Code:200 OK
Remote Address:[::1]:80
Response Headers
view source
Connection:Keep-Alive
Content-Type:text/html
Date:Fri, 14 Apr 2017 04:31:10 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.10 (Win32) OpenSSL/0.9.8zb mod_fcgid/2.3.9
Transfer-Encoding:chunked
X-Powered-By:PHP/5.4.33
Request Headers
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:zh-CN,zh;q=0.8,en;q=0.6
Connection:keep-alive
Host:localhost
Referer:http://localhost/086_refresh.php
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

禁用浏览器缓存:

<?php
//通过header来禁用缓存(ajax)
    header("Expires:-1");
    header("Cache-Control:no_cache");
    header("");
    //上边写的那些是为了兼容浏览器禁用缓存的
    echo "hello cache";
?>

抓包看效果:

General:
Request URL:http://localhost/086_nocache.php
Request Method:GET
Status Code:200 OK
Remote Address:[::1]:80
Response Headers
HTTP/1.1 200 OK
Date: Fri, 14 Apr 2017 08:40:46 GMT
Server: Apache/2.4.10 (Win32) OpenSSL/0.9.8zb mod_fcgid/2.3.9
X-Powered-By: PHP/5.4.33
Expires: -1
Cache-Control: no_cache
Pragma: no_cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
Request Headers
GET /086_nocache.php HTTP/1.1
Host: localhost
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: zh-CN,zh;q=0.8,en;q=0.6
Go-Request 是 HTTP 客户端请求包,灵感来源于 Python Requests。 安装 go get -u github.com/mozillazg/request 文档 API 文档:https://godoc.org/github.com/mozillazg/request 使用 import (     "github.com/mozillazg/request" ) GET: c := new(http.Client) req := request.NewRequest(c) resp, err := req.Get("http://httpbin.org/get") j, err := resp.Json() defer resp.Body.Close()  // Don't forget close the response body POST: req.Data = map[string]string{     "key": "value",     "a":   "123", } resp, err := req.Post("http://httpbin.org/post") Cookies: req.Cookies = map[string]string{     "key": "value",     "a":   "123", } resp, err := req.Get("http://httpbin.org/cookies") Headers: req.Headers = map[string]string{     "Accept-Encoding": "gzip,deflate,sdch",     "Accept": "text/html,application/xhtml xml,application/xml;q=0.9,image/webp,*/*;q=0.8", } resp, err := req.Get("http://httpbin.org/get") Files: f, err := os.Open("test.txt") req.Files = []request.FileField{     request.FileField{"file", "test.txt", f}, }resp, err := req.Post("http://httpbin.org/post") Json: req.Json = map[string]string{    "a": "A",    "b": "B", }resp, err := req.Post("http://httpbin.org/post") req.Json = []int{1, 2, 3} resp, err = req.Post("http://httpbin.org/post") Proxy: req.Proxy = "http://127.0.0.1:8080" // req.Proxy = "https://127.0.0.1:8080" // req.Proxy = "socks5://127.0.0.1:57341" resp, err := req.Get("http://httpbin.org/get") or https://github.com/mozillazg/request/tree/develop/_example/proxy HTTP Basic Authentication: req.BasicAuth = request.BasicAuth{"user", "passwd"} resp, err := req.Get("http://httpbin.org/basic-auth/user/passwd") 标签:GoRequest
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

有时有晌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值