Why not ask your question on the new OpenStreetMap Community Forum?

IE doesn't like 'mixed content', i.e. both https and https. A badly worded warning is pushed into the face of the user. Now Chrome is beginning to give warnings, too.

So if you have an aplication that is secured with https, and get tiles directly from OSM (that only serves via http), the user will be distracted by bogous warnings.

Solution: cook your own forwarding proxy that serves tiles via https.

(The old trick to just return a redirect (301, 'Moved Permanently') to the real osm URL no longer works so well, and is btw slow).

For extra flavour, add caching. It's easy; it only takes 10-20 lines of Java servlet code. This both increases map load speed and reduces load on the osm server. :-) just keep the tiles in files, and re-read if file.lastModfied is older than y hours.

Now, here's the question. How long should such a forward proxy cache a tile? One hour? One day? Some other value?

asked 14 Nov '11, 09:31

tmpsa's gravatar image

accept rate: 0%

edited 14 Nov '11, 17:23

Jonathan%20Bennett's gravatar image

Jonathan Ben...

Cache Tile downloads locally according to HTTP Expiry Header, alternatively a minimum of 7 days.

From the Tile Usage Policy.

permanent link

answered 14 Nov '11, 10:28

Richard's gravatar image

Richard ♦
accept rate: 18%


I can't parse that statement. It's, um, a bit terse. What, exactly, does it mean?

(14 Nov '11, 10:57) tmpsa

If you don't know what an HTTP Expiry header is, cache for seven days.

(14 Nov '11, 17:22) Jonathan Ben...

The Tile Usage Policy states that you should

Cache Tile downloads locally according to HTTP Expiry Header, alternatively a minimum of 7 days.

Every tile is served with a bunch of HTTP headers, some of which let the client know how long they should cache the tiles for. You don't normally have access to the HTTP headers, but you can find them out using various tools, such as curl -I. For example:

~$ curl -I http://tile.openstreetmap.org/0/0/0.png
HTTP/1.0 200 OK
Content-Length: 8574
Access-Control-Allow-Origin: *
Content-Type: image/png
Date: Mon, 14 Nov 2011 21:37:16 GMT
Server: Apache/2.2.14 (Ubuntu)
ETag: "e1d1be17c7acd4b4cb5fb8e233fb929e"
Expires: Sun, 20 Nov 2011 22:47:03 GMT
Cache-Control: max-age=522587
Age: 24
X-Cache: HIT from konqi.openstreetmap.org
X-Cache-Lookup: HIT from konqi.openstreetmap.org:3128
Via: 1.1 konqi.openstreetmap.org:3128 (squid/2.7.STABLE9)
Connection: close

The Expires header says that you would cache this tile until the date and time shown. The tile server uses a variety of mechanisms to estimate the length of time each tile should be cached, including how recently it was redrawn, what zoom level its on and so on.

Most caching proxies will, by default, read and use the dates shown in the Expiry header, and you probably won't have to do any configuration. If your caching proxy for some reason can't read the Expiry header, you should configure it to cache everything for 7 days instead.

permanent link

answered 14 Nov '11, 21:45

Andy%20Allan's gravatar image

Andy Allan
accept rate: 28%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 14 Nov '11, 09:31

question was seen: 7,113 times

last updated: 14 Nov '11, 21:45

powered by OSQA