aboutsummaryrefslogtreecommitdiffstats
path: root/patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch')
-rw-r--r--patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch23
1 files changed, 17 insertions, 6 deletions
diff --git a/patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch b/patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch
index c81432a..17154a9 100644
--- a/patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch
+++ b/patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch
@@ -1,19 +1,30 @@
-From 1288a202b61cf01fbff8a8bd0071e57383aa954e Mon Sep 17 00:00:00 2001
+From b2d83e4d7e17d2a6d1fe8efa19e74d4f1eb1d64c Mon Sep 17 00:00:00 2001
From: Christian Hesse <mail@eworm.de>
Date: Fri, 21 May 2021 09:52:34 +0200
Subject: [PATCH 1/1] support http header 'Cache-Control: no-cache' for soft
failure
-By setting the HTTP header 'Cache-Control: no-cache' when returning with
+The idea has been borrowed from cloud providers' reverse proxies and
+load balancers. These accept http headers to control caching behaviour,
+even to control 'negative caching' when error codes are returned.
+
+By setting the http header 'Cache-Control: no-cache' when returning with
the status code 404 (not found) the server can indicate that this is a
soft failure. No error message is shown, and server's error count is
not increased.
This can be used by servers that are not expected to be complete, for
example when serving a local cache [0]. In nginx this can be achived by
-adding a single directive in location block:
+acting on error_page and sending the extra header by adding a directive:
- add_header Cache-Control "no-cache";
+ server {
+ listen 8080 default_server;
+ root /var/cache/pacman/pkg;
+ error_page 404 = @no-cache;
+ location @no-cache {
+ add_header Cache-Control "no-cache" always;
+ }
+ }
Also this is a perfect match for pacredir [1].
@@ -26,7 +37,7 @@ Signed-off-by: Christian Hesse <mail@eworm.de>
1 file changed, 11 insertions(+)
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
-index 4fa17b35..23034584 100644
+index 4fa17b35..74462bba 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -274,8 +274,10 @@ static size_t dload_parseheader_cb(void *ptr, size_t size, size_t nmemb, void *u
@@ -44,7 +55,7 @@ index 4fa17b35..23034584 100644
}
}
-+ /* By setting the HTTP header 'Cache-Control: no-cache' the server can indicate
++ /* By setting the http header 'Cache-Control: no-cache' the server can indicate
+ that this is a soft failure which should not be cached. No error message is
+ shown, and server's error count is not increased. */
+ if(_alpm_raw_ncmp(cc_header, ptr, strlen(cc_header)) == 0) {