0

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.

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.

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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