Introduction to the OpenGeo Suite

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.

  1. Make sure you’re logged in and working with a new map

  2. Click the Add Layers button in the layers window pane.

  3. In the Available Layers panel, click the Add a New Server button.

    ../_images/gwc_publish-01.png

    Adding a new WMS server

  4. In the URL field, enter the URL of our cached layers:

    http://localhost:8080/geoserver/gwc/service/wms
  5. Click Add Server, to connect to the GeoWebCache server.

    ../_images/gwc_publish-02.png

    Our WMS server endpoint

  6. 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.

  7. Highlight the layers we added previously from the pure WMS, click Add Layers and then Done.

    ../_images/gwc_publish-03.png

    Our layers in the GeoExplorer Available Layers dialog

  8. Right-click on the earthgroup, and select Zoom to Layer Extent.

    ../_images/gwc_publish-04.png

    Layer context menu

  9. You should see a happy map of the world.

    ../_images/gwc_publish-05.png

    Map with layers added

  10. Click the Export Map icon.

  11. Select your toolbar items, and then click Next to view HTML block used to embed your map in a web page.

    ../_images/gwc_publish-06.png

    Export map dialog

  12. 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>
    
  13. 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.

    ../_images/gwc_publish-07.png

    HTML source code with two <iframes>

  14. Save your GNN page and refresh your browser.

    ../_images/gwc_publish-08.png

    A happier web page

  15. 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.

    ../_images/gwc_publish-09.png

    Two maps, but only one is accelerated

Continue Reading

Previous: Seeding

Next: Part 6: Building Custom Web Map Applications

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.

Creative Commons License