에 항상 응답을 전송
Volley는 캐시 항목이 아직 만료되지 않았 음을 감지하면 서버에 요청을 전혀 발행하지 않습니다.
// If it is completely expired, just send it to the network.
if (entry.isExpired()) {
request.addMarker("cache-hit-expired");
request.setCacheEntry(entry);
mNetworkQueue.put(request);
continue;
}
그리고 : : 여기를 증명할 수있는 코드 발췌은
if (!entry.refreshNeeded()) {
// Completely unexpired cache hit. Just deliver the response.
mDelivery.postResponse(request, response);
} else {
// Soft-expired cache hit. We can deliver the cached response,
// but we need to also send the request to the network for
// refreshing.
request.addMarker("cache-hit-refresh-needed");
request.setCacheEntry(entry);
// Mark the response as intermediate.
response.intermediate = true;
// Post the intermediate response back to the user and have
// the delivery then forward the request along to the network.
mDelivery.postResponse(request, response, new Runnable() {
@Override
public void run() {
try {
mNetworkQueue.put(request);
} catch (InterruptedException e) {
// Not much we can do about this.
}
}
});
}
당신은 클라이언트에서 캐시를 조정할하기 위해 Cache-Control
또는 Expires
헤더에 max-age
을 설정하여 서버에 자원 만료를 제어 할 수 있습니다 측면.