mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Add some useful HTTP cache debug output.
This commit is contained in:
parent
13a43e69e0
commit
b347cf877c
1 changed files with 10 additions and 0 deletions
|
@ -297,6 +297,7 @@ fn create_cached_response(
|
||||||
cached_headers: &HeaderMap,
|
cached_headers: &HeaderMap,
|
||||||
done_chan: &mut DoneChannel,
|
done_chan: &mut DoneChannel,
|
||||||
) -> CachedResponse {
|
) -> CachedResponse {
|
||||||
|
debug!("creating a cached response for {:?}", request.url());
|
||||||
let resource_timing = ResourceFetchTiming::new(request.timing_type());
|
let resource_timing = ResourceFetchTiming::new(request.timing_type());
|
||||||
let mut response = Response::new(
|
let mut response = Response::new(
|
||||||
cached_resource.data.metadata.data.final_url.clone(),
|
cached_resource.data.metadata.data.final_url.clone(),
|
||||||
|
@ -305,6 +306,7 @@ fn create_cached_response(
|
||||||
response.headers = cached_headers.clone();
|
response.headers = cached_headers.clone();
|
||||||
response.body = cached_resource.body.clone();
|
response.body = cached_resource.body.clone();
|
||||||
if let ResponseBody::Receiving(_) = *cached_resource.body.lock().unwrap() {
|
if let ResponseBody::Receiving(_) = *cached_resource.body.lock().unwrap() {
|
||||||
|
debug!("existing body is in progress");
|
||||||
let (done_sender, done_receiver) = unbounded();
|
let (done_sender, done_receiver) = unbounded();
|
||||||
*done_chan = Some((done_sender.clone(), done_receiver));
|
*done_chan = Some((done_sender.clone(), done_receiver));
|
||||||
cached_resource
|
cached_resource
|
||||||
|
@ -571,8 +573,10 @@ impl HttpCache {
|
||||||
done_chan: &mut DoneChannel,
|
done_chan: &mut DoneChannel,
|
||||||
) -> Option<CachedResponse> {
|
) -> Option<CachedResponse> {
|
||||||
// TODO: generate warning headers as appropriate <https://tools.ietf.org/html/rfc7234#section-5.5>
|
// TODO: generate warning headers as appropriate <https://tools.ietf.org/html/rfc7234#section-5.5>
|
||||||
|
debug!("trying to construct cache response for {:?}", request.url());
|
||||||
if request.method != Method::GET {
|
if request.method != Method::GET {
|
||||||
// Only Get requests are cached, avoid a url based match for others.
|
// Only Get requests are cached, avoid a url based match for others.
|
||||||
|
debug!("non-GET method, not caching");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let entry_key = CacheKey::new(request.clone());
|
let entry_key = CacheKey::new(request.clone());
|
||||||
|
@ -588,6 +592,7 @@ impl HttpCache {
|
||||||
let original_request_headers = cached_resource.request_headers.lock().unwrap();
|
let original_request_headers = cached_resource.request_headers.lock().unwrap();
|
||||||
if let Some(vary_value) = cached_headers.typed_get::<Vary>() {
|
if let Some(vary_value) = cached_headers.typed_get::<Vary>() {
|
||||||
if vary_value.is_any() {
|
if vary_value.is_any() {
|
||||||
|
debug!("vary value is any, not caching");
|
||||||
can_be_constructed = false
|
can_be_constructed = false
|
||||||
} else {
|
} else {
|
||||||
// For every header name found in the Vary header of the stored response.
|
// For every header name found in the Vary header of the stored response.
|
||||||
|
@ -602,6 +607,7 @@ impl HttpCache {
|
||||||
// Check that the value of the nominated header field,
|
// Check that the value of the nominated header field,
|
||||||
// in the original request, matches the value in the current request.
|
// in the original request, matches the value in the current request.
|
||||||
if original_header_data != header_data {
|
if original_header_data != header_data {
|
||||||
|
debug!("headers don't match, not caching");
|
||||||
can_be_constructed = false;
|
can_be_constructed = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -613,6 +619,9 @@ impl HttpCache {
|
||||||
// were also absent in the original request.
|
// were also absent in the original request.
|
||||||
can_be_constructed =
|
can_be_constructed =
|
||||||
original_request_headers.get(vary_val).is_none();
|
original_request_headers.get(vary_val).is_none();
|
||||||
|
if !can_be_constructed {
|
||||||
|
debug!("vary header present, not caching");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if !can_be_constructed {
|
if !can_be_constructed {
|
||||||
|
@ -663,6 +672,7 @@ impl HttpCache {
|
||||||
return Some(cached_response);
|
return Some(cached_response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
debug!("couldn't find an appropriate response, not caching");
|
||||||
// The cache wasn't able to construct anything.
|
// The cache wasn't able to construct anything.
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue