Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

OpenLayers introduced client side caching in Version 2.11 and 2.12, along side their performance improvements for other map functions. Needless to say, these functions are intertwined and rely on each other so I don't think I can just pull out the caching code and use it with version 2.10.

Is there any way to force the client browser to cache the map tiles and re-use them on subsequent requests? I am hoping this can be done for my WMS TileCache tiles retrieved from my ms4w Apache server.

Cheers


Here is a live example on my host: http://www.spatialanalysis.ca/cachemytiles/ Check out the network panel for my WMS layer and then check the OSM base layer. The OSM base layer returns "from cache" tiles once they've been loaded once. I have a feeling this is an Apache setup option?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

I was indeed correct with my hypothesis.

The correct way to set up Apache so that our requests are never duplicated unless required is to set a Expires mod in the HTTPD.conf file.

First, enable the module:

LoadModule expires_module modules/mod_expires.so

Then, turn on caching for PNG images:

ExpiresActive on
ExpiresByType image/png "access plus 1 year"

Since my TileCache is generated once using a pre-seeding script and I don't expect to have to regenerate the images any time in the near future, I can safely set my Expires time to 1 year. Alternatives are 1 day, 1 month, and so on. Note that a hard refresh will dump the client cache and tiles will be requested as usual from the server.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.