Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Only return cache header on success
Sebastian Martinez committed 2 years ago
commit 22c83c556f54249acf6613d4df9c2cd5e5ba876e
parent 3fb08329abbd40c85a3c44f37b3f8d37ea7c6420
1 file changed +7 -2
modified radicle-httpd/src/api/v1/projects.rs
@@ -3,7 +3,7 @@ use std::collections::{BTreeMap, HashMap};
use axum::extract::{DefaultBodyLimit, State};
use axum::handler::Handler;
use axum::http::{header, HeaderValue};
-
use axum::response::IntoResponse;
+
use axum::response::{IntoResponse, Response};
use axum::routing::{get, patch, post};
use axum::{Json, Router};
use axum_auth::AuthBearer;
@@ -43,7 +43,12 @@ pub fn router(ctx: Context) -> Router {
            get(
                activity_handler.layer(SetResponseHeaderLayer::if_not_present(
                    header::CACHE_CONTROL,
-
                    HeaderValue::from_static(CACHE_1_HOUR),
+
                    |response: &Response| {
+
                        response
+
                            .status()
+
                            .is_success()
+
                            .then_some(HeaderValue::from_static(CACHE_1_HOUR))
+
                    },
                )),
            ),
        )