How control openlayers local caching of tiles?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How control openlayers local caching of tiles?

Uggla Henrik
Hi!

Openlayers seems to cache tiled WMS layers (but not single tile) locally in the browser. I need to be able to clear the cache when a user clicks a button but haven't managed to find out how to do it. In Firebug I can see the browser loading the tiles from the source the first time but when loaded a second time it doesn't send a request at all but loads the tiles from some sort of local cache. Even when all caching is disabled in Firefox tiles are still cached locally. The only way to clear the cache is to reload the whole page with ctrl+F5 (only F5 doesn't work). Using php to destroy the session doesn't work either. I've also tried to add a TileManager for the map but it doesn't seem to be active and clearing it does nothing. Then I've tried the CacheWrite control, executing clearCache. Once again, no effect. I've also tried to set html headers cache-control, pragma etc. but the tiles are still cached. Can someone please explain how to control that cache?

Regards
Henrik
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: How control openlayers local caching of tiles?

Uggla Henrik
Oh, I forgot to mention that we are using Openlayers-2.13.1.

/H

________________________________
Från: Uggla Henrik
Skickat: den 21 augusti 2014 15:27
Till: [hidden email]
Ämne: How control openlayers local caching of tiles?

Hi!

Openlayers seems to cache tiled WMS layers (but not single tile) locally in the browser. I need to be able to clear the cache when a user clicks a button but haven't managed to find out how to do it. In Firebug I can see the browser loading the tiles from the source the first time but when loaded a second time it doesn't send a request at all but loads the tiles from some sort of local cache. Even when all caching is disabled in Firefox tiles are still cached locally. The only way to clear the cache is to reload the whole page with ctrl+F5 (only F5 doesn't work). Using php to destroy the session doesn't work either. I've also tried to add a TileManager for the map but it doesn't seem to be active and clearing it does nothing. Then I've tried the CacheWrite control, executing clearCache. Once again, no effect. I've also tried to set html headers cache-control, pragma etc. but the tiles are still cached. Can someone please explain how to control that cache?

Regards
Henrik
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: How control openlayers local caching of tiles?

D_Guidi
In reply to this post by Uggla Henrik
On Thu, Aug 21, 2014 at 3:27 PM, Uggla Henrik
<[hidden email]> wrote:
> In Firebug I can see the browser loading the tiles from the source the first time but when loaded a second time it doesn't send a request at all but loads the tiles from some sort of local cache.

I think you're referring to browser cache, something that is outside
of control of openlayers code.
Simply speaking: a tile is an url requested via a GET, and if url
doesn't change, browser thinks (correctly, most of times) that
resource is the same.
The only way to address this issue is to make a different url: you can
do this calling explicitely HttpRequest.redraw(true):
http://goo.gl/2AeKza



Diego Guidi
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users