[OpenLayers-Users] prevent browser cache

Tim Schaub noreply at geocartic.com
Tue Jan 23 14:13:08 EST 2007


> for dynamically changing data browser cache on images could 
> be an unwanted feature. Chameleon for instance always appends 
> a random parameter to the url to prevent the browser cache 
> from coming into play.
> 
> Is there such a switch in OpenLayers, i.e. to keep urls 
> unique? If not, at which level (Map, Layer, WMS, Untiled?) 
> would it be appropriate to have such a switch?

This may not suit all, but I think this is best handled at the application
level (i.e. not in the library).  I assume that you have some function that
is triggering the redraw of your layer.  You could trigger the redraw with
something like:

myLayer.mergeNewParams({'TTT': OpenLayers.Util.createUniqueID('ttt')});

Doing it this way (instead of in Untiled.js) gives you a bit more
flexibility in determining when the image should or should not be cached.

Does that work for you?

Tim

> 
> For now I have changed getURL in Untiled.js to get the 
> behaviour I wanted:
> 
>     getURL: function(bounds) {
>         var tileSize = this.map.getSize();
>         tileSize.w = tileSize.w * this.ratio;
>         tileSize.h = tileSize.h * this.ratio;
>         return this.getFullRequestString( {'BBOX': bounds.toBBOX(),
>                                                   'WIDTH': tileSize.w,
>                                                   'HEIGHT': 
> tileSize.h,
> 'TTT': OpenLayers.Util.createUniqueID('ttt')} );
>     },
> 
> Hope to hear some discussion on this subject.
> 
> Best regards,
> Bart
> 




More information about the Users mailing list