Geowebcache瓦片的自更新
目录
问题来源
如果有一种图层,它的支撑数据是不断变化的,但使用wms加载太慢(gwc/service/wms也一样),影响体验,那么有没有办法,加载事先切好的瓦片,再自更新更换的部分?
解决方式
- geoserver官网上提供的两种方式(guava是自带的,而另一种则需要使用社区封装好的依赖包),但两种都试过了,貌似都没有什么效果,也可能是我的方法不对,望大神指点
- 利用gwc自带的配置进行瓦片时效的调整,用这种方式,本人确实在时长之外感受到了瓦片的变化。
GWC瓦片配置步骤
- 以防有人不记得所配置的路径,特地介绍了如何找到配置路径,打开geoserver,进入主页,修改地址子路径为gwc(如localhost:8080/geoserver/gwc)。
- 在xml中添加需要的图层,结构可自行百度geowebcache.xml,有详细的结构,这里不重复,在<layers>下添加所需的wmsLayer.
<layers> <wmsLayer> <name>随便的名称</name> <metaInformation> <title>Nicer title for Image States</title> <description>This is a description. Fascinating.</description> </metaInformation> <mimeFormats> <string>image/png8</string> </mimeFormats> <gridSubsets> <gridSubset> <gridSetName>EPSG:4326</gridSetName> <extent> <coords> <double>106.54</double> <double>21.59</double> <double>108.26</double> <double>23.2</double> </coords> </extent> </gridSubset> </gridSubsets> <expireCacheList><!--缓存时效--> <expirationRule minZoom="0" expiration="60" /> <expirationRule minZoom="1" expiration="60" /> <expirationRule minZoom="2" expiration="60" /> </expireCacheList> <expireClientsList><!--客户端时效--> <expirationRule minZoom="0" expiration="60" /> <expirationRule minZoom="1" expiration="60" /> <expirationRule minZoom="2" expiration="60" /> </expireClientsList> <wmsUrl> <string>http://最好外网:端口/geoserver/wms</string> </wmsUrl> <wmsLayers>工作区:图层名称</wmsLayers> <transparent>true</transparent> <bgColor>0x0066FF</bgColor> </wmsLayer> </layers>
- 然后在第一步的网址里加子路径demo,选中Reload Configuration,进行配置的重新读取
- 继续下来,要注意的是,配置文件的图层很可能被原来配置的同名图层给顶替掉了,导致结果没有发生变化,这里要删除掉原有图层才能看到GWC图层,如图,图标可以区分,很明显框起来的就是通过配置生成的图层,这个图层可以自更新瓦片。
注意
最大的注意事项就是注意有没有顶替现象
转载自:https://blog.csdn.net/u013323965/article/details/71480810