Tag: 套接字的

我应该在收到304后closures代理连接吗?

我有一个HTTP请求/回应问题。 比方说,我有一个代理服务器,只是将客户端的请求转发给第三方服务器,第三方服务器的回应给客户端: var http = require('http'); var url = require('url'); http.createServer(function (req, res) { var opts = { hostname : 'www.example.com', port : 80, path : req.url, method : req.method, headers : req.headers }; opts.headers.host = opts.host; var proxyReq = http.request(opts, function (proxyResponse) { res.writeHead(proxyResponse.statusCode, proxyResponse.headers); proxyResponse.pipe(res); }); req.pipe(proxyReq); }).listen(3000); 假设客户端是caching感知的(比如浏览器),并且它传递了一个if-modified-since或者if-none-match (或者其他)头部,导致第三方服务器响应一个304状态码。 在技​​术上,服务器不应该发送一个正文,客户端在收到304之后不关心响应主体。 通过在服务器的代理响应处理程序中这样做是否有意义(并且会节省任何带宽/资源),这些服务器错误地使用304: var […]