+--On 5 juillet 2010 17:27:03 +0200 Moataz Elmasry <[email protected]> wrote: | Hello List | | I use http://tile.openstreetmap.org/${z}/${x}/${y}.png to display the map | in my web application | I use a filter mechanism in the servlet, where an expiry header and | maximum age headers are added to the image requests, so that they will be | cached for a while on the client browser. These are just for common | images that the application use like tooltip.png and button.png and | such...These are called from the cache just fine | | Now to do the same for osm tiles I added a proxy through which the tiles | are requested and then expiry headers are added to these tiles, Say | http://myapplciation.com/proxy?url=http://tile.openstreetmap.org/${z}/${x | }/${y}.png. This is the layer address in OpenLayers.Layer.OSM | | An expiry header is added correctly to osm tiles. The problem is that the | imagename in the request is different than in the response, so if I'm | requesting |http://tile.openstreetmap.org/16/34687/21558.png I get an | image called 2736BB16d01.png in my cache. So that by the next call this | image won't be fetched from the cache and instead called again from the | server and so on. | | Is there a way to force the browser to load the images from its cache if | available?
Well, you should not create a new expire header, but you should forward the expires and etag from the original request, and try to use that etag header : $ curl -I http://tile.openstreetmap.org/16/34687/21558.png HTTP/1.0 200 OK Date: Mon, 05 Jul 2010 15:27:25 GMT Server: Apache/2.2.8 (Ubuntu) ETag: "ae22fe7a91ce525e988b2da52f63a4a4" Content-Length: 16897 Cache-Control: max-age=18482 Expires: Mon, 05 Jul 2010 20:35:27 GMT Content-Type: image/png Age: 1360 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.STABLE7) Connection: close $ curl -H 'If-None-Match: "ae22fe7a91ce525e988b2da52f63a4a4"' -I http://tile.openstreetmap.org/16/34687/21558.png HTTP/1.0 304 Not Modified Date: Mon, 05 Jul 2010 15:27:25 GMT Content-Type: image/png Expires: Mon, 05 Jul 2010 20:35:27 GMT ETag: "ae22fe7a91ce525e988b2da52f63a4a4" Age: 1392 X-Cache: HIT from konqi.openstreetmap.org X-Cache-Lookup: HIT from konqi.openstreetmap.org:3128 Via: 1.0 konqi.openstreetmap.org:3128 (squid/2.7.STABLE7) Connection: close It should be more effective than what you're trying to achieve. (I think.) -- Mathieu Arnold _______________________________________________ dev mailing list [email protected] http://lists.openstreetmap.org/listinfo/dev

