From 2a64fa789a683fc98ac6a9012a9279a31ce8cbf7 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Sun, 5 Aug 2018 22:02:15 +0100 Subject: [PATCH 1/1] Force caching of 410 on openlayers 404 tile ExpiresDefault only returns headers on 2xx responses so set the headers manually for the 410 response Also set a long expiry for redirect from http and other domains. Closes #178 --- .../web/templates/default/apache.frontend.erb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cookbooks/web/templates/default/apache.frontend.erb b/cookbooks/web/templates/default/apache.frontend.erb index 6cbf86418..6e8ab95ed 100644 --- a/cookbooks/web/templates/default/apache.frontend.erb +++ b/cookbooks/web/templates/default/apache.frontend.erb @@ -59,8 +59,13 @@ # # Block requests for the old 404 map tile + # and force cache headers on response # - RewriteRule ^/openlayers/img/404.png$ - [G,L] + + Header always set Cache-Control "max-age=31536000" + Header always set Expires "Tue, 19 Jan 2038 03:14:08 GMT" + RewriteRule ^ - [G,L] + # # Block attempts to access old API versions @@ -265,12 +270,15 @@ ServerName openstreetmap.org ServerAlias * + Header always set Cache-Control "max-age=31536000" + Header always set Expires "Tue, 19 Jan 2038 03:14:08 GMT" + RewriteEngine on RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L] RewriteCond %{REQUEST_URI} !^/server-status$ - RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent] + RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent] @@ -281,6 +289,9 @@ SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key + Header always set Cache-Control "max-age=31536000" + Header always set Expires "Tue, 19 Jan 2038 03:14:08 GMT" + RedirectPermanent / https://www.openstreetmap.org/ -- 2.43.2