Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ where
let method = request.method();
let uri = request.uri();

let key = storage_key(method, uri);
if matches!(*method, Method::GET | Method::HEAD) {
let key = storage_key(method, uri);
match self.storage.get(&key).await {
Ok(Some((response, policy))) => {
debug!(
Expand Down Expand Up @@ -351,14 +351,16 @@ where
}
}

self.send_upstream(request, CacheLookupStatus::Miss).await
self.send_upstream(key, request, CacheLookupStatus::Miss)
.await
}

/// Sends the original request upstream.
///
/// Caches the response if the response is cacheable.
async fn send_upstream<B: HttpBody>(
&self,
key: String,
request: impl Request<B>,
lookup_status: CacheLookupStatus,
) -> Result<Response<Body<B>>> {
Expand All @@ -370,7 +372,6 @@ where

response.set_cache_status(lookup_status, CacheStatus::Miss);

let key = storage_key(&request_like.method, &request_like.uri);
if matches!(request_like.method, Method::GET | Method::HEAD)
&& response.status() == StatusCode::OK
&& policy.is_storable()
Expand Down