@@ -18,6 +18,7 @@ map service syntax for SOAP/HTTP POST
18
18
***************************************************************************/
19
19
20
20
#include " qgsapplication.h"
21
+ #include " qgscapabilitiescache.h"
21
22
#include " qgsconfigcache.h"
22
23
#include " qgsgetrequesthandler.h"
23
24
#include " qgssoaprequesthandler.h"
@@ -191,6 +192,9 @@ int main( int argc, char * argv[] )
191
192
}
192
193
}
193
194
195
+ // create cache for capabilities XML
196
+ QgsCapabilitiesCache capabilitiesCache;
197
+
194
198
// creating QgsMapRenderer is expensive (access to srs.db), so we do it here before the fcgi loop
195
199
QgsMapRenderer* theMapRenderer = new QgsMapRenderer ();
196
200
@@ -291,20 +295,34 @@ int main( int argc, char * argv[] )
291
295
292
296
if ( requestIt->second == " GetCapabilities" )
293
297
{
294
- QDomDocument capabilitiesDocument;
295
- try
298
+ const QDomDocument* capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument ( configFilePath );
299
+ if ( !capabilitiesDocument ) // capabilities xml not in cache. Create a new one
300
+ {
301
+ QgsMSDebugMsg ( " Capabilities document not found in cache" );
302
+ QDomDocument doc;
303
+ try
304
+ {
305
+ doc = theServer->getCapabilities ();
306
+ }
307
+ catch ( QgsMapServiceException& ex )
308
+ {
309
+ theRequestHandler->sendServiceException ( ex );
310
+ delete theRequestHandler;
311
+ delete theServer;
312
+ continue ;
313
+ }
314
+ capabilitiesCache.insertCapabilitiesDocument ( configFilePath, &doc );
315
+ capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument ( configFilePath );
316
+ }
317
+ else
296
318
{
297
- capabilitiesDocument = theServer-> getCapabilities ( );
319
+ QgsMSDebugMsg ( " Found capabilities document in cache " );
298
320
}
299
- catch ( QgsMapServiceException& ex )
321
+
322
+ if ( capabilitiesDocument )
300
323
{
301
- theRequestHandler->sendServiceException ( ex );
302
- delete theRequestHandler;
303
- delete theServer;
304
- continue ;
324
+ theRequestHandler->sendGetCapabilitiesResponse ( *capabilitiesDocument );
305
325
}
306
- QgsMSDebugMsg ( " sending GetCapabilities response" );
307
- theRequestHandler->sendGetCapabilitiesResponse ( capabilitiesDocument );
308
326
delete theRequestHandler;
309
327
delete theServer;
310
328
continue ;
0 commit comments