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.
In the URL field, enter the URL of our cached layers:
Click Add Server, to connect to the GeoWebCache server.
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.
Right-click on the earthgroup, and select Zoom to Layer Extent.
You should see a happy map of the world.
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.
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.
Save your GNN page and refresh your browser.
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.
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.