From 1843371641f5b3898893df91094412eaeedc8807 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 21 May 2025 23:45:10 +0200 Subject: HTTPd: Use `Content-Type: application/x-empty` for 404 error pages. This matches PHP's finfo_file() behavior for empty files, cf. https://stackoverflow.com/questions/24015038/why-does-php-file-info-return-inode-x-empty-for-empty-text-files --- files/etc/nginx/sites-available/webmap | 6 ++++-- tasks/httpd.yml | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/files/etc/nginx/sites-available/webmap b/files/etc/nginx/sites-available/webmap index 6921c2c..32937fa 100644 --- a/files/etc/nginx/sites-available/webmap +++ b/files/etc/nginx/sites-available/webmap @@ -65,7 +65,8 @@ server { expires 8h; brotli_static on; try_files $uri =404; - error_page 404 /_.txt; + # service an empty payload to save bandwidth + error_page 404 /_empty; } location = /tiles/metadata.json { expires epoch; @@ -73,11 +74,12 @@ server { try_files $uri =404; } - location = /_.txt { + location = /_empty { # cache 404 responses for 8h like for valid tiles add_header Strict-Transport-Security "max-age=31557600; includeSubDomains" always; add_header Cache-Control "public; max-age=28800" always; #add_header Access-Control-Allow-Origin "*" always; + default_type application/x-empty; internal; } diff --git a/tasks/httpd.yml b/tasks/httpd.yml index 2e1fa98..ea2dee0 100644 --- a/tasks/httpd.yml +++ b/tasks/httpd.yml @@ -55,8 +55,8 @@ owner=root group=root mode=0755 -- name: Create /var/www/webmap/_.txt - copy: dest=/var/www/webmap/_.txt content="" +- name: Create /var/www/webmap/_empty + copy: dest=/var/www/webmap/_empty content="" owner=root group=root mode=0644 -- cgit v1.2.3