]> git.openstreetmap.org Git - chef.git/commitdiff
Force caching of 410 on openlayers 404 tile
authorGrant Slater <git@firefishy.com>
Sun, 5 Aug 2018 21:02:15 +0000 (22:02 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 5 Aug 2018 21:35:52 +0000 (22:35 +0100)
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

cookbooks/web/templates/default/apache.frontend.erb

index 6cbf8641808b4b6d9085e691091ac2d12b47e1c5..6e8ab95ed132f2f53658134c55a7ee7e10e053d5 100644 (file)
 
   #
   # Block requests for the old 404 map tile
+  # and force cache headers on response
   #
-  RewriteRule ^/openlayers/img/404.png$ - [G,L]
+  <Location /openlayers/img/404.png>
+    Header always set Cache-Control "max-age=31536000"
+    Header always set Expires "Tue, 19 Jan 2038 03:14:08 GMT"
+    RewriteRule ^ - [G,L]
+  </Location>
 
   #
   # Block attempts to access old API versions
   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]
 </VirtualHost>
 
 <VirtualHost *:443>
   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/
 </VirtualHost>