文件内容
server.js
const http = require('http');
const fs = require('fs');
http.createServer(function(req, res) {
console.log('request come', req.url);
if (req.url === '/') {
res.writeHead(302, {
"Location": "/new",
})
res.end(' ')
}
if (req.url === '/new') {
res.writeHead(200, {
"Content-Type": "text/html",
})
res.end("aaa")
}
}).listen(8888)
console.log('server start at port 8888')
302
每一次请求/,都会先走/,然后再走/new
301
客户端不清除缓存的情况下
- 服务端设置了301之后,只有第一次会先/再转/new
- 以后输入/,都会直接转/new,不会经过/
客户端清除缓存
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。