当我第一次在浏览器中访问http://129.0.1.23/时,将启动DoSomething()函数,并将URL重定向到http://129.0.1.23/index.html?id=10&name=jack
当我再次访问http://129.0.1.23/时,功能DoSomething()未启动,浏览器似乎已缓存网址http://129.0.1.23/,浏览器转到http://129.0.1.23/index.html?id=10&name=jack直接通过缓存。
如何让浏览器不缓存网址?谢谢!
@Override
public Response serve(IHTTPSession session) {
String uri = session.getUri();
if (uri.endsWith("/")){
String muri =uri+"index.html?id=10&name=jack";
DoSomething();
return RedirectWebPage(muri);
}
return null;
}
private Response RedirectWebPage(String uri){
Response res = newFixedLengthResponse(Response.Status.REDIRECT,
NanoHTTPD.MIME_HTML,
"<html><body>Redirected: <a href=\"" + uri + "\">" + uri + "</a></body></html>");
res.addHeader("Location", uri);
return res;
}