[mapserver-users] Getting Browsers to cache mapserv URLs

Stephen Lime steve.lime at dnr.state.mn.us
Mon May 7 12:28:09 EDT 2001


I've had a great deal of success with caching just by using GET urls. That seems to work
just fine with browser caches although I don't know if server caching systems can use it.
I would suspect yes. I suppose you could control timeouts etc with metadata in resulting
templates. I know there there other issues that make this impractical for some applications
especially when just retrieving images that have no metadata. One could add configure
parameters to set "freshness" in the HTTP headers.

Since the mapserv CGI is stateless caching is not a simple undertaking. Besides knowing
if the application or data has changed the app would have to look at extent, layer and other
settings. You want to serve old content only if the exact (or within some fudge factor) map
or query has been processed before. I think that will take bookkeeping well beyond what the 
web server can handle and would have to be implemented within the MapServer itself not
with HTTP headers.

For a quick-and-dirty solution I think GET urls with addendums to the HTTP headers is the
best bet. A more complex solution that would support things like approximate extents (i.e. a
user requests a map *very*, 1 or 2 pixels, from a previously created map so send the old one)
is a good idea but is a ways off unless other want to work on it as a separate module.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> Cameron Shorter <cameron at socialchange.net.au> 05/05/01 06:10AM >>>
mapserver-users,

We would like to improve the speed of our applications by enabling the
caching of mapserv maps.
The idea is that you design your mapping application to encourage uses
to use default map extents so that they can reuse map images from local
cache.

However, for caching to work, the mapserv cgi script needs to:
1. Return a "Last-Modified:" field in header.
2. Read the cgi request parameters, recognise the
$HTTP_IF_MODIFIED_SINCE parameter, and return "Status: 304 Not
Modified\n\n" if the map has not changed since the last query.

(There are a few other network issues, but they can be addressed
seperately.)

I'm interested to know:
1. Would others find this feature useful?
2. How best to implement this?
3. How should we work out the date for the "Last-Modified:" timestamp?
* The quick and dirty option would be to use the timestamp of the .map
file.
* A better solution would be to check the time stamps of all the layers
and .map file, and take the latest.
4. Should caching be rolled into all versions, or be an option at
compile time?
5. Does anyone have any experience with caching, or example C code that
we could use?

References
==========
Short description of writing cache pages for CGI scripts
http://vancouver-webpages.com/CacheNow/detail.html#CGI 

An example perl program which uses caching
http://vancouver-webpages.com/proxy/log-tail.pl 

General Article on caching
http://www.mnot.net/cache_docs/ 
In particular, how caching applies to CGI scripts
http://www.mnot.net/cache_docs/#SCRIPT 


-- 
Cameron Shorter          Web Mapping Manager
Social Change Online
248 Johnson St           Tel: +61 (0) 2 9692 5115
Annandale NSW 2038       Fax: +61 (0) 2 9692 5192
Sydney, Australia        http://webmap.socialchange.net.au




More information about the mapserver-users mailing list