Caching On-Demand¶
We don’t really need to do much to cache tiles on demand. We just need to request map images from our WMS through the tile proxy and GeoWebCache takes care of everything else.
In this section we’ll configure a GeoExplorer map to use cached images from GWC over-top of our local WMS, and then compare cached delivery times with full WMS requests, on our GNN web-page.
Adding a GWC Server¶
To publish a cached map, let’s return to GeoExplorer.
Make sure you’re logged in and working with a new map
Click the Add Layers button in the layers window pane.
In the Available Layers panel, click the Add a New Server button.
Adding a new WMS server
In the URL field, enter the URL of our cached layers:
http://localhost:8080/geoserver/gwc/service/wms
Click Add Server, to connect to the GeoWebCache server.
Our WMS server endpoint
A familiar list of layers will display. The layers in GeoWebCache are the configured GeoServer layers currently being served by GeoServer. This list of layers is identical to both the GeoWebCache configuration page and the GeoServer WMS layer list.
Highlight the layers we added previously from the pure WMS, click Add Layers and then Done.
Our layers in the GeoExplorer Available Layers dialog
Right-click on the earthgroup, and select Zoom to Layer Extent.
Layer context menu
You should see a happy map of the world.
Map with layers added
Click the Export Map icon.
Select your toolbar items, and then click Next to view HTML block used to embed your map in a web page.
Export map dialog
Copy the <iframe> HTML. We will be pasting this text (or something very similar) into our GNN page:
<iframe style="border: none;" height="400" width="600" src="http://localhost:8080/geoexplorer/viewer#maps/2"> </iframe>
Return to your text editor and scroll down to about line 32. Above the previous iframe paste the latest HTML code. You should now have two maps in your GNN page: the first served by GeoWebCache, the second served by GeoServer.
HTML source code with two <iframes>
Save your GNN page and refresh your browser.
A happier web page
Get your two maps to roughly the same extent. Zoom and pan the first map, and then zoom and pan the second map. You might notice a rendering delay the first time you request a new area on the map that uses caching, but that delay won’t happen if you return to the same area. That is not the case with the original map, where rendering times remain consistently slower.
Two maps, but only one is accelerated
Table Of Contents
This Page
About OpenGeo
OpenGeo provides commercial open source software for internet mapping and geospatial application development. We are a social enterprise dedicated to the growth and support of open source software.
License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License. Feel free to use this material, but we ask that you please retain the OpenGeo branding, logos and style.

