Skip to content

support http header 'Cache-Control: no-cache' for soft failure

Christian Hesse requested to merge eworm/pacman:404-no-cache into master

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

Merge request reports