From 2778b3ac84b697f8e3412d281f6a05c8f0c6bbd2 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Wed, 7 Aug 2019 20:57:23 +0200 Subject: [PATCH] Don't cache redirects --- backend/src/main.rs | 4 ++++ backend/src/service.rs | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/src/main.rs b/backend/src/main.rs index 20bd518..315056d 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -80,6 +80,10 @@ fn redirect( LOCATION, T::redirect_url(&data.user, &data.repo, &head, &data.file).as_str(), ) + .set(CacheControl(vec![ + CacheDirective::Public, + CacheDirective::MaxAge(0), + ])) .finish() })); } diff --git a/backend/src/service.rs b/backend/src/service.rs index 4f1e924..fac8330 100644 --- a/backend/src/service.rs +++ b/backend/src/service.rs @@ -4,7 +4,10 @@ use crate::{ statics::{load_env_var, GITHUB_AUTH_QUERY, OPT}, }; use actix_web::{ - http::{header::LOCATION, StatusCode}, + http::{ + header::{CacheControl, CacheDirective, LOCATION}, + StatusCode, + }, web, Error, HttpResponse, }; use awc::{error::PayloadError, Client, ClientResponse}; @@ -268,6 +271,10 @@ impl Service for GitLab { ) .as_str(), ) + .set(CacheControl(vec![ + CacheDirective::Public, + CacheDirective::MaxAge(0), + ])) .finish() }) .from_err(),