[GIS] Using WFS Caching / Back button

cachegeoserveropenlayers-2postgiswfs

I'm using WFS protocol on Vector layer / GeoServer / PostGIS

Currently the map is refreshing and calling new requests whenever i do anything like searching or drawing and when i move back to a part of the map which previously had features already downloaded, it refreshes and call new request again. i need to reuse previous data for previous requests.

I've read that the OpenLayers does not have this functionality. but this was a long time ago.

Is there a way to cache wfs returns by check the boolean in top of the code or anything like that ?

That will help me implement my BACK button so that i can store previous requests in a stack and pull requests when the user clicks the back button.

Best Answer

HTTP POST requests are not normally cached - see this StackOverflow question: https://stackoverflow.com/questions/626057/is-it-possible-to-cache-post-methods-in-http

However if you switch your WFS layer to use GET requests rather than POST requests then these requests can be cached.

I had to apply a patch to my OpenLayers installation to get this to work correctly - http://trac.osgeo.org/openlayers/ticket/2718

Then you can set the WFS method to be GET when creating the layer (in the options parameter).