我为自己构建的机器人开发了自己的自定义 Web 服务器(视频),但并不真正了解 HTTP 的复杂性。我遇到的一个问题是我从浏览器发送一个请求,比如说,http://192.168.2.10/r?cmd=doStuff
机器人做出响应。然后我再次从浏览器发送相同的请求(通过单击我保存的书签),请求永远不会消失,它只是显示上一个请求的响应。
以下是来自浏览器(尤其是 IE8)的内容:
GET /r?cmd=s HTTP/1.1
Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; InfoPath.2; .NET4.0C; .NET4.0E; Zune 4.7)
Accept-Encoding: gzip, deflate
Host: 192.168.2.10
Connection: Keep-Alive
机器人响应如下:
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Server: The Little Robot That Could 1.0
Date: Thu, 01 Jan 2009 00:05:00 GMT
Content-Length: 4
X-Powered-By: Little Robot HTTP Server
我是否需要在混合中添加一些其他 HTTP 标头以防止浏览器缓存响应?