Caching OSM tiles
Cedric Jeanneret
cedric.jeanneret at camptocamp.com
Tue May 11 14:20:27 MSD 2010
On Tue, 11 May 2010 11:34:32 +0400
Igor Sysoev <igor at sysoev.ru> wrote:
> On Tue, May 11, 2010 at 08:37:19AM +0200, Cedric Jeanneret 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.
>
>
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 :
- true,url:'http://tile.openstreetmap.org/${z}/${x}/${y}
+ true,url:'http://tiles.internux.ch/${z}/${x}/${y}
It just works fine.
Beware of cache size - mine is a small one as I'm not coverring a big area.
Thanks again.
C.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20100511/995c172f/attachment.pgp>
More information about the nginx
mailing list