gpt4 book ai didi

Android避免缓存

转载 作者:太空狗 更新时间:2023-10-29 16:18:06 25 4
gpt4 key购买 nike

// http client
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;

// Checking http request method type
if (method == POST) {
HttpPost httpPost = new HttpPost(url);
// adding post params
if (params != null) {
httpPost.setEntity(new UrlEncodedFormEntity(params));
}
httpResponse = httpClient.execute(httpPost);
} else if (method == GET) {
// appending params to url
if (params != null) {
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
}
HttpGet httpGet = new HttpGet(url);
httpResponse = httpClient.execute(httpGet);
}
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);

当我进行服务器调用时,它会带来数据...我第二次调用它时,它会带来缓存...并且不会调用服务器...我该如何解决这个问题?

我不想缓存。

最佳答案

您可以将以下 HTTP header 添加到您的请求中:Cache-Control: no-cache

httpGet.addHeader("Cache-Control", "no-cache");

关于Android避免缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21980684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com