HTT prequest没有缓存 [英] HttpRequest without caching

查看:153
本文介绍了HTT prequest没有缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写正在为XML数据随时间变化的重复HTTP请求的客户端。它看起来像Android的堆栈缓存我的页面请求,并多次返回相同的页面。我如何确保每次都得到一个新的一页?

I'm writing a client that is making repeated http requests for xml data that is changing over time. It looks like the Android stack is caching my page requests and returning the same page repeatedly. How do I make sure it gets a fresh page each time?

- code ---

-- code ---

HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response;
    response = client.execute(request);

InputStream in;
in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));

谢谢, 格里

Thanks, Gerry

推荐答案

添加一个HTTP标头:

add a HTTP header:

的Cache-Control:no-cache的

Cache-Control: no-cache

和是否正常工作。

这篇关于HTT prequest没有缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆