Caching OSM tiles

Hello!

I’m currently developping a really tiny app using OpenLayers[1] and
OpenStreetMap[2].
As I was testing it, I saw that sometimes tiles don’t come. I guess this
is caused by server load at OSM. So I was thinking about caching some
tiles so that it won’t overload OSM, and my app will work nicely.

Has anybody ever tried it ? if so, how can we do it ?
If no one has tested/tried it, any hints/ideas ?

I guess I should configure a special vhost like “tiles.domain.ltd”,
proxy-ing tiles.openstreetmap.org, with some caching, and tell
OpenLayers to use OSM tiles through this proxy. Right ?

Thank you for your answers.

Best regards,

C. Jeanneret

[1] http://openlayers.org/
[2] http://www.openstreetmap.org/

On Tue, May 11, 2010 at 08:37:19AM +0200, Cedric J. wrote:

Hello!

I’m currently developping a really tiny app using OpenLayers[1] and OpenStreetMap[2].
As I was testing it, I saw that sometimes tiles don’t come. I guess this is caused by server load at OSM. So I was thinking about caching some tiles so that it won’t overload OSM, and my app will work nicely.

Has anybody ever tried it ? if so, how can we do it ?
If no one has tested/tried it, any hints/ideas ?

I guess I should configure a special vhost like “tiles.domain.ltd”, proxy-ing tiles.openstreetmap.org, with some caching, and tell OpenLayers to use OSM tiles through this proxy. Right ?

Yes.


Igor S.
http://sysoev.ru/en/

On Tue, 11 May 2010 11:34:32 +0400
Igor S. [email protected] wrote:

I guess I should configure a special vhost like “tiles.domain.ltd”, proxy-ing tiles.openstreetmap.org, with some caching, and tell OpenLayers to use OSM tiles through this proxy. Right ?

Yes.

Just for the posterity:

proxy_cache_path /home/tilecache levels=1:2:2
keys_zone=tilecache:1536m;

server {
listen 94.23.198.39:80;
server_name tiles.domain.ltd;

access_log /var/log/nginx/tiles_access.log main;
error_log /var/log/nginx/tiles_error.log info;
location / {
proxy_pass http://tile.openstreetmap.org/ ;
proxy_cache tilecache;
proxy_cache_key “$scheme$host$request_uri”;
proxy_cache_valid 200 302 300h;
proxy_cache_valid 404 1m;
}
}

And I modified openlayers.js in this way :

It just works fine.

Beware of cache size - mine is a small one as I’m not coverring a big
area.

Thanks again.

C.