aboutsummaryrefslogtreecommitdiffstats
path: root/patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-06-02 13:49:05 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-11-24 08:31:59 +0100
commitcc57e3469b9475e06ab1d5fd2093e1ae563e54eb (patch)
tree37019c5c7307de7e24a029f22569f60c7f5c1938 /patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch
parent2abd33d55c18da4af4ac7540c12598527eb2a81a (diff)
downloadpacredir-cc57e3469b9475e06ab1d5fd2093e1ae563e54eb.tar.gz
pacredir-cc57e3469b9475e06ab1d5fd2093e1ae563e54eb.tar.zst
add a CacheServer entry in pacman configuration snippet...pacman-v6.1.0
... comment the regular server entry and update the documentation in README file. The server error limit was introduced in pacman 6.0.0, which caused some trouble with pacredir: Returning 404 (not found) is common case and no fatal error. This should be fixed with pacman 7.0.0, that will understand CacheServer in configuration. Hopefully. Add the required bits in include file for pacman.
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.patch69
1 files changed, 0 insertions, 69 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
deleted file mode 100644
index 17154a9..0000000
--- a/patches/0001-support-http-header-Cache-Control-no-cache-for-soft-failure.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-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
-
-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
-acting on error_page and sending the extra header by adding a directive:
-
- 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].
-
-[0] https://wiki.archlinux.org/title/Pacman/Tips_and_tricks#Network_shared_pacman_cache
-[1] https://git.eworm.de/cgit/pacredir/about/
-
-Signed-off-by: Christian Hesse <mail@eworm.de>
----
- lib/libalpm/dload.c | 11 +++++++++++
- 1 file changed, 11 insertions(+)
-
-diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
-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
- {
- size_t realsize = size * nmemb;
- const char *fptr, *endptr = NULL;
-+ const char * const cc_header = "Cache-Control:";
- const char * const cd_header = "Content-Disposition:";
- const char * const fn_key = "filename=";
-+ const char * const nc_key = "no-cache";
- struct dload_payload *payload = (struct dload_payload *)user;
- long respcode;
-
-@@ -302,6 +304,15 @@ static size_t dload_parseheader_cb(void *ptr, size_t size, size_t nmemb, void *u
- }
- }
-
-+ /* 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) {
-+ if(strstr(ptr, nc_key)) {
-+ payload->errors_ok = 1;
-+ }
-+ }
-+
- curl_easy_getinfo(payload->curl, CURLINFO_RESPONSE_CODE, &respcode);
- if(payload->respcode != respcode) {
- payload->respcode = respcode;