Index: branches/prototype-v0/zoo-project/zoo-kernel/caching.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/caching.c	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/caching.c	(revision 863)
@@ -142,4 +142,82 @@
  * @param max_path the size of the allocated filepath buffer  
  */
+void cacheFile(maps* conf,char* request,char* mimeType,int length,char* filename){
+  map* tmp=getMapFromMaps(conf,"main","cacheDir");
+  char contentr[4096];
+  int cred=0;
+  if(tmp!=NULL){
+    char* myRequest=getFilenameForRequest(conf,request);
+    char* md5str=getMd5(myRequest);
+    free(myRequest);
+    char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6));
+    sprintf(fname,"%s/%s.zca",tmp->value,md5str);
+    zooLock* lck=lockFile(conf,fname,'w');
+    if(lck!=NULL){
+#ifdef DEBUG
+      fprintf(stderr,"Cache list : %s\n",fname);
+      fflush(stderr);
+#endif
+      FILE* fi=fopen(filename,"rb");
+      FILE* fo=fopen(fname,"w+");
+      if(fo==NULL){
+#ifdef DEBUG
+	fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno));
+#endif
+	unlockFile(conf,lck);
+	return;
+      }
+      if(fi==NULL){
+#ifdef DEBUG
+	fprintf (stderr, "Failed to open %s for reading: %s\n",filename, strerror(errno));
+#endif
+	unlockFile(conf,lck);
+	return;
+      }
+      memset(contentr,0,4096);
+      while((cred=fread(contentr,sizeof(char),4096,fi))>0){
+	fwrite(contentr,sizeof(char),cred,fo);
+	fflush(fo);
+	memset(contentr,0,4096);
+      }
+      unlockFile(conf,lck);
+      fclose(fo);
+      fclose(fi);
+	
+      sprintf(fname,"%s/%s.zcm",tmp->value,md5str);
+      fo=fopen(fname,"w+");
+#ifdef DEBUG
+      fprintf(stderr,"MIMETYPE: %s\n",mimeType);
+#endif
+      fwrite(mimeType,sizeof(char),strlen(mimeType),fo);
+      fclose(fo);
+
+      sprintf(fname,"%s/%s.zcp",tmp->value,md5str);
+      fo=fopen(fname,"w+");
+      char* origin=getProvenance(conf,request);
+#ifdef DEBUG
+      fprintf(stderr,"ORIGIN: %s\n",mimeType);
+#endif
+      fwrite(origin,sizeof(char),strlen(origin),fo);
+      fclose(fo);
+
+      free(md5str);
+      free(fname);
+    }
+  }
+}
+
+/**
+ * Cache a file for a given request.
+ * For each cached file, the are two files stored, a .zca and a .zcm containing
+ * the downloaded content and the mimeType respectively. 
+ *
+ * @param conf the maps containing the settings of the main.cfg file
+ * @param request the url used too fetch the content
+ * @param content the downloaded content
+ * @param mimeType the content mimeType 
+ * @param length the content size
+ * @param filepath a buffer for storing the path of the cached file; may be NULL
+ * @param max_path the size of the allocated filepath buffer  
+ */
 void addToCache(maps* conf,char* request,char* content,char* mimeType,int length, 
                 char* filepath, size_t max_path){
@@ -243,9 +321,10 @@
 int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet,map** error){
   
+  int shouldClean=-1;
   map* tmp1;
   char sindex[5];
   maps* content=*in;
   map* length=getMap(content->content,"length");
-  int shouldClean=-1;
+  map* memUse=getMapFromMaps(*m,"main","memory");
   if(length==NULL){
     length=createMap("length","1");
@@ -266,4 +345,5 @@
     char hname[11];
     char oname[12];
+    char ufile[12];    
     if(*index>0)
       sprintf(vname1,"value_%d",*index);
@@ -282,4 +362,5 @@
       sprintf(hname,"headers_%d",i);
       sprintf(oname,"Order_%d",i);
+      sprintf(ufile,"use_file_%d",i);
     }else{
       sprintf(cname,"cache_file");
@@ -292,4 +373,5 @@
       sprintf(hname,"headers");
       sprintf(oname,"Order");
+      sprintf(ufile,"use_file");
     }
     
@@ -298,16 +380,18 @@
     if((tmp1=getMap(content->content,xname))!=NULL && tmap!=NULL && strcasecmp(tmap->value,sindex)==0){
 
-      if(getMap(content->content,icname)==NULL){
-	fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char));
-	if(fcontent == NULL){
-	  errorException(*m, _("Unable to allocate memory"), "InternalError",NULL);
-	  return -1;
-	}
-	size_t dwRead;
-	InternetReadFile(hInternet->ihandle[*index], 
-			 (LPVOID)fcontent, 
-			 hInternet->ihandle[*index].nDataLen, 
-			 &dwRead);
-	fcontent[hInternet->ihandle[*index].nDataLen]=0;
+      if(getMap(content->content,icname)==NULL) {
+	if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
+	  fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char));
+	  if(fcontent == NULL){
+	    errorException(*m, _("Unable to allocate memory"), "InternalError",NULL);
+	    return -1;
+	  }
+	  size_t dwRead;
+	  InternetReadFile(hInternet->ihandle[*index], 
+			   (LPVOID)fcontent, 
+			   hInternet->ihandle[*index].nDataLen, 
+			   &dwRead);
+	  fcontent[hInternet->ihandle[*index].nDataLen]=0;
+	}
 	fsize=hInternet->ihandle[*index].nDataLen;
 	if(hInternet->ihandle[*index].mimeType==NULL)
@@ -317,10 +401,13 @@
 	
 	map* tmpMap=getMapOrFill(&(*in)->content,vname,"");
-	free(tmpMap->value);
-	tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
-	if(tmpMap->value==NULL){
-	  return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL);
-	}
-	memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
+	if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
+	  free(tmpMap->value);
+	  tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
+	  if(tmpMap->value==NULL){
+	    return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL);
+	  }
+	  memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
+	}else
+	  addToMap((*in)->content,ufile,"true");
 	if(hInternet->ihandle[*index].code!=200){
 	  char *error_rep_str=_("Unable to download the file for the input <%s>, response code was : %d.");
@@ -376,6 +463,11 @@
 	addToMap((*in)->content,sname,ltmp1);
 	addToMap((*in)->content,mname,mimeType);
-	addToCache(*m,request,fcontent,mimeType,fsize, NULL, 0);
-	free(fcontent);
+	if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
+	  addToCache(*m,request,fcontent,mimeType,fsize, NULL, 0);
+	  free(fcontent);
+	}else{
+	  addToMap((*in)->content,ufile,"true");
+	  cacheFile(*m,request,mimeType,fsize,hInternet->ihandle[*index].filename);
+	}
 	free(mimeType);
 	free(request);
@@ -388,4 +480,5 @@
     free(length);
   }
+  dumpMaps(*in);
   return 0;
 }
@@ -438,5 +531,5 @@
   hInternet->waitingRequests[hInternet->nb]=strdup(url);
   if(req)
-    InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
+    InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0,*m);
   maps *oreq=getMaps(*m,"orequests");
   if(oreq==NULL){
@@ -465,4 +558,5 @@
   char *mimeType=NULL;
   int fsize=0;
+  map* memUse=getMapFromMaps(*m,"main","memory");
 
   map* t=getMap(*content,"xlink:href");
@@ -479,10 +573,14 @@
       if(lck==NULL)
 	return -1;
-      fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
-      FILE* f=fopen(cached,"rb");
-      fread(fcontent,f_status.st_size,1,f);
       fsize=f_status.st_size;
-      fcontent[fsize]=0;
-      fclose(f);
+      if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
+	fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
+	FILE* f=fopen(cached,"rb");
+	if(f!=NULL){
+	  fread(fcontent,f_status.st_size,1,f);
+	  fcontent[fsize]=0;
+	  fclose(f);
+	}
+      }
       addToMap(*content,"cache_file",cached);
       unlockFile(*m,lck);
@@ -513,15 +611,20 @@
 
   map* tmpMap=getMapOrFill(content,"value","");
-  free(tmpMap->value);
-  tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
-  if(tmpMap->value==NULL || fcontent == NULL)
-    return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL);
-  memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
-
+  if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
+    free(tmpMap->value);
+    tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
+    if(tmpMap->value==NULL || fcontent == NULL)
+      return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL);
+    memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
+  }
+  
   char ltmp1[256];
   sprintf(ltmp1,"%d",fsize);
   addToMap(*content,"size",ltmp1);
   if(cached==NULL){
-    addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0);
+    if(memUse!=NULL && strcasecmp(memUse->value,"load")==0)
+      addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0);
+    else
+      cacheFile(*m,url,mimeType,fsize,hInternet->ihandle[hInternet->nb-1].filename);
   }
   else{
Index: branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c	(revision 863)
@@ -759,5 +759,6 @@
 							   xmlStrlen(btmps),
 							   INTERNET_FLAG_NO_CACHE_WRITE,
-							   0);
+							   0,
+							   *main_conf);
 					  addIntToMap (tmpmaps->content, "Order", hInternet->nb);
 					}
@@ -795,5 +796,6 @@
 						   [0], NULL, 0,
 						   INTERNET_FLAG_NO_CACHE_WRITE,
-						   0);
+						   0,
+						   *main_conf);
 				processDownloads (&bInternet);
 				char *tmp =
@@ -830,5 +832,6 @@
 						       strlen(tmp),
 						       INTERNET_FLAG_NO_CACHE_WRITE,
-						       0);
+						       0,
+						       *main_conf);
 				    addIntToMap (tmpmaps->content, "Order", hInternet->nb);
 				  }
Index: branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c	(revision 863)
@@ -125,4 +125,6 @@
     char *tmp1;
     map *tmpStatus;
+    maps* tmpConf=createMaps("main");
+    tmpConf->content=createMap("memory","load");
     hInternet=InternetOpen("ZooWPSClient\0",
 			   INTERNET_OPEN_TYPE_PRECONFIG,
@@ -178,8 +180,10 @@
 			    (char*)jsonStr, strlen(jsonStr),
 			    INTERNET_FLAG_NO_CACHE_WRITE,
-			    0);
+			    0,tmpConf);
     AddHeaderEntries(&hInternet,arg->conf);
     //curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_VERBOSE, 1);x
     processDownloads(&hInternet);
+    freeMaps(&tmpConf);
+    free(tmpConf);
     now = time ( NULL );
     tm = localtime ( &now );
Index: branches/prototype-v0/zoo-project/zoo-kernel/service_internal_java.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/service_internal_java.c	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/service_internal_java.c	(revision 863)
@@ -427,4 +427,6 @@
 #endif
       map* sizeV=getMap(tmp1,"size");
+      map* useFile=getMap(tmp1,"use_file");
+      map* cacheFile=getMap(tmp1,"cache_file");
       map* isArray=getMap(tmp1,"isArray");
       map* alen=getMap(tmp1,"length");
@@ -432,5 +434,5 @@
 	if(strcmp(tmp1->name,"value")==0){
 	  if(isArray==NULL){
-	    if(sizeV!=NULL && strcmp(tmp1->name,"value")==0){
+	    if(sizeV!=NULL && strcmp(tmp1->name,"value")==0 && useFile==NULL){
 #ifdef JAVA7
 	      jbyteArray tmpData=(*env).NewByteArray(atoi(sizeV->value));
@@ -448,4 +450,11 @@
 	      (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
 #endif
+	      if(useFile!=NULL)
+#ifdef JAVA7
+		(*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF("cache_file"), (*env).NewStringUTF(cacheFile->value));
+#else
+	        (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,"cache_file"), (*env)->NewStringUTF(env,cacheFile->value));
+#endif
+	      
 	  }
 	  else{
@@ -455,5 +464,5 @@
 	    jclass scArrayListClass,scArrayList_class;
 	    jmethodID scArrayList_constructor;
-	    jobject scObject2;
+	    jobject scObject2,scObject3;
 #ifdef JAVA7
 	    scArrayListClass = (*env).FindClass("java/util/ArrayList");
@@ -462,4 +471,5 @@
 	    jmethodID add_mid = 0;
 	    scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
+	    scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
 
 	    add_mid = (*env).GetMethodID(scArrayListClass,
@@ -471,4 +481,5 @@
 	    jmethodID add_mid = 0;
 	    scObject2 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
+	    scObject3 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
 
 	    add_mid = (*env)->GetMethodID(env,scArrayListClass,
@@ -478,9 +489,11 @@
 	    
 	    for(i=0;i<alen1;i++){
+	      map* cMap=getMapArray(tmp->content,"cache_file",i);
+	      map* uMap=getMapArray(tmp->content,"use_file",i);
 	      map* vMap=getMapArray(tmp->content,"value",i);
 	      map* sMap=getMapArray(tmp->content,"size",i);
 	      map* mMap=getMapArray(tmp->content,tmap->value,i);
 	      
-	      if(sMap!=NULL && vMap!=NULL && strncmp(vMap->name,"value",5)==0){
+	      if(sMap!=NULL && vMap!=NULL && strncmp(vMap->name,"value",5)==0 && uMap==NULL){
 #ifdef JAVA7
 		jbyteArray tmpData=(*env).NewByteArray(atoi(sMap->value));
@@ -501,11 +514,23 @@
 #endif
 	      }
-	      
+
+	      if(cMap!=NULL){
+#ifdef JAVA7
+		jobject tmpData=(*env).NewStringUTF(cMap->value);
+		(*env).CallObjectMethod(scObject3, add_mid, tmpData);
+#else
+		jobject tmpData=(*env)->NewStringUTF(env,cMap->value);
+		(*env)->CallObjectMethod(env,scObject3, add_mid, tmpData);
+#endif
+
+	      }
 	    }
 
 #ifdef JAVA7
 	    (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), scObject2);
+	    (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF("cache_file"), scObject3);
 #else	    
 	    (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), scObject2);
+	    (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,"cache_file"), scObject3);
 #endif
 
Index: branches/prototype-v0/zoo-project/zoo-kernel/service_internal_js.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/service_internal_js.c	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/service_internal_js.c	(revision 863)
@@ -901,4 +901,6 @@
   char* tmpValue;
   size_t dwRead;
+  maps *tmpConf=createMaps("main");
+  tmpConf->content=createMap("memory","load");
   JS_MaybeGC(cx);
   hInternet=InternetOpen("ZooWPSClient\0",
@@ -929,5 +931,5 @@
 #endif
     InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body),
-		    INTERNET_FLAG_NO_CACHE_WRITE,0);    
+		    INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf);    
     processDownloads(&hInternet);
     free(body);
@@ -940,10 +942,10 @@
 	}
 	InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0,
-			INTERNET_FLAG_NO_CACHE_WRITE,0);
+			INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf);
 	processDownloads(&hInternet);
       }else{
 	char *body=JSValToChar(cx,&argv[2]);
 	InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body),
-			INTERNET_FLAG_NO_CACHE_WRITE,0);
+			INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf);
 	processDownloads(&hInternet);
 	free(body);
@@ -951,5 +953,5 @@
     }else{
       InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0,
-		      INTERNET_FLAG_NO_CACHE_WRITE,0);
+		      INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf);
       processDownloads(&hInternet);
     }
@@ -972,4 +974,6 @@
   if(argc>=2)
     free(method);
+  freeMaps(&tmpConf);
+  free(tmpConf);
   InternetCloseHandle(&hInternet);
   JS_MaybeGC(cx);
Index: branches/prototype-v0/zoo-project/zoo-kernel/service_internal_python.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/service_internal_python.c	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/service_internal_python.c	(revision 863)
@@ -425,4 +425,6 @@
   map* isArray=getMap(tmp,"isArray");
   map* size=getMap(tmp,"size");
+  map* useFile=getMap(tmp,"use_file");
+  map* cacheFile=getMap(tmp,"cache_file");
   map* tmap=getMapType(tmp);
   while(tmp!=NULL){
@@ -435,9 +437,12 @@
 	PyObject* mvalue=PyList_New(cnt);
 	PyObject* svalue=PyList_New(cnt);
+	PyObject* cvalue=PyList_New(cnt);
 
 	for(int i=0;i<cnt;i++){
 	  
-	  map* vMap=getMapArray(tmp,"value",i);	    
-	  map* sMap=getMapArray(tmp,"size",i);
+	  map* vMap=getMapArray(t,"value",i);
+	  map* uMap=getMapArray(t,"use_file",i);
+	  map* sMap=getMapArray(t,"size",i);
+	  map* cMap=getMapArray(t,"cache_file",i);
 
 	  if(vMap!=NULL){
@@ -445,13 +450,21 @@
 	    PyObject* lvalue;
 	    PyObject* lsvalue;
-	    if(sMap==NULL){
+	    PyObject* lcvalue;
+	    if(sMap==NULL || uMap!=NULL){
 	      lvalue=PyString_FromString(vMap->value);
-	      lsvalue=Py_None;
 	    }
 	    else{    
 	      lvalue=PyString_FromStringAndSize(vMap->value,atoi(sMap->value));
+	    }
+	    if(sMap!=NULL){
 	      lsvalue=PyString_FromString(sMap->value);
 	      hasSize=1;
 	    }
+	    else
+	      lsvalue=Py_None;
+	    if(uMap!=NULL){
+	      lcvalue=PyString_FromString(cMap->value);;
+	    }else
+	      lcvalue=Py_None;
 
 	    if(PyList_SetItem(value,i,lvalue)<0){
@@ -463,8 +476,12 @@
 	      return NULL;
 	    } 
+	    if(PyList_SetItem(cvalue,i,lcvalue)<0){
+	      fprintf(stderr,"Unable to set key value pair...");
+	      return NULL;
+	    }
 	  }
 	  
+	  PyObject* lmvalue;
 	  map* mMap=getMapArray(tmp,tmap->name,i);
-	  PyObject* lmvalue;
 	  if(mMap!=NULL){
 	    lmvalue=PyString_FromString(mMap->value);
@@ -487,4 +504,8 @@
 	  return NULL;
 	}
+	if(PyDict_SetItem(res,PyString_FromString("cache_file"),cvalue)<0){
+	  fprintf(stderr,"Unable to set key value pair...");
+	  return NULL;
+	}
 	if(hasSize>0)
 	  if(PyDict_SetItem(res,PyString_FromString("size"),svalue)<0){
@@ -493,5 +514,5 @@
 	  }
       }
-      else if(size!=NULL){
+      else if(size!=NULL && useFile==NULL){
 	PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value));
 	if(PyDict_SetItem(res,name,value)<0){
Index: branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ruby.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ruby.c	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ruby.c	(revision 863)
@@ -260,4 +260,5 @@
   int hasSize=0;
   map* isArray=getMap(tmp,"isArray");
+  map* useFile=getMap(tmp,"use_file");
   map* size=getMap(tmp,"size");
   map* tmap=getMapType(tmp);
@@ -271,4 +272,5 @@
 	VALUE mvalue=rb_ary_new2(cnt);
 	VALUE svalue=rb_ary_new2(cnt);
+	VALUE cvalue=rb_ary_new2(cnt);
 
 	for(int i=0;i<cnt;i++){
@@ -276,4 +278,6 @@
 	  map* vMap=getMapArray(tmp,"value",i);	    
 	  map* sMap=getMapArray(tmp,"size",i);
+	  map* uMap=getMapArray(tmp,"use_file",i);
+	  map* cMap=getMapArray(tmp,"cache_file",i);
 
 	  if(vMap!=NULL){
@@ -281,7 +285,11 @@
 	    VALUE lvalue;
 	    VALUE lsvalue;
-	    if(sMap==NULL){
+	    VALUE lcvalue;
+	    if(sMap==NULL || uMap==NULL){
 	      lvalue=rb_str_new2(vMap->value);
-	      lsvalue=Qnil;
+	      if(sMap==NULL)
+		lsvalue=Qnil;
+	      else
+		lsvalue=rb_str_new2(sMap->value);
 	    }
 	    else{
@@ -290,7 +298,12 @@
 	      hasSize=1;
 	    }
+	    if(uMap!=NULL)
+	      lcvalue=rb_str_new2(cMap->value);
+	    else
+	      lcvalue=Qnil;
 
 	    rb_ary_push(value,lvalue);
 	    rb_ary_push(svalue,lsvalue);
+	    rb_ary_push(cvalue,lcvalue);
 	  }
 	  
@@ -308,4 +321,6 @@
 	rb_hash_aset(res, name, mvalue);
 	rb_hash_aset(res, rb_str_new2(tmap->name), mvalue);
+	VALUE lname0=rb_str_new2("cache_size");
+	rb_hash_aset(res, lname0, value);
       
 	if(hasSize>0){
Index: branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c	(revision 863)
@@ -379,11 +379,5 @@
   char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(msg->value)+strlen(p->value)+strlen(sid->value)+64+1)*sizeof(char));
   sprintf(sqlQuery,"UPDATE %s.services set status=$$%s$$,message=$$%s$$ where uuid=$$%s$$;",schema->value,p->value,msg->value,sid->value);
-  if( zoo_ds_nb==
-#ifdef META_DB
-      1
-#else
-      0
-#endif     
-     ){
+  if( zoo_ds_nb == 0 ){
     init_sql(conf);
     zoo_ds_nb++;
Index: branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c	(revision 863)
@@ -70,5 +70,5 @@
 
 /**
- * Write the downloaded content to a _HINTERNET structure
+ * Write the downloaded content in the file pouted by the _HINTERNET structure
  *
  * @param buffer the buffer to read
@@ -89,9 +89,7 @@
    psInternet=(_HINTERNET *)data;
    writen+=fwrite(buffer, size, nmemb, psInternet->file);
-   if(psInternet->nDataLen>0){
-     psInternet->nDataAlloc+=psInternet->nDataLen+writen+1;
-     psInternet->nDataLen += realsize;
-   }else
-     psInternet->nDataLen=realsize+1;
+   fflush(psInternet->file);
+   psInternet->nDataLen += realsize;
+
    buffer=NULL;
    return realsize;
@@ -443,10 +441,13 @@
  * @param dwFlags desired download mode (INTERNET_FLAG_NO_CACHE_WRITE for not using cache file)
  * @param dwContext not used
+ * @param conf the main configuration file maps pointer
  * @return the updated HINTERNET 
  */
-HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext){
+HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext,const maps* conf){
 
   char filename[255];
+  int ldwFlags=INTERNET_FLAG_NEED_FILE;
   struct MemoryStruct header;
+  map* memUse=getMapFromMaps(conf,"main","memory");
 
   hInternet->ihandle[hInternet->nb].handle=curl_easy_init( );
@@ -480,6 +481,9 @@
   curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_VERBOSE, 1);
 #endif
-      
-  switch(dwFlags)
+
+  if(memUse!=NULL && strcasecmp(memUse->value,"load")==0)
+    ldwFlags=INTERNET_FLAG_NO_CACHE_WRITE;
+  
+  switch(ldwFlags)
     {
     case INTERNET_FLAG_NO_CACHE_WRITE:
@@ -491,5 +495,14 @@
       memset(filename,0,255);
       char* tmpUuid=get_uuid();
-      sprintf(filename,"/tmp/ZOO_Cache%s", tmpUuid);
+      map* tmpPath=NULL;
+      if(conf!=NULL){
+	tmpPath=getMapFromMaps(conf,"main","tmpPath");
+      }
+      if(tmpPath==NULL)
+	sprintf(filename,"/tmp/ZOO_Cache%s", tmpUuid);
+      else
+	sprintf(filename,"/%s/ZOO_Cache%s", tmpPath->value,tmpUuid);
+      fprintf(stderr," *** %s %d %s",__FILE__,__LINE__,filename);
+      fflush(stderr);
       free(tmpUuid);
       hInternet->ihandle[hInternet->nb].filename=strdup(filename);
Index: branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h
===================================================================
--- branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h	(revision 862)
+++ branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h	(revision 863)
@@ -100,4 +100,6 @@
   size_t write_data_into(void*,size_t,size_t,void*);
 
+  size_t write_data_into_file(void*,size_t,size_t,void*);
+
   size_t header_write_data(void*,size_t,size_t,void*);
 
@@ -158,5 +160,5 @@
 #  define CHECK_INET_HANDLE(h) (h.handle != 0)
 
-  HINTERNET InternetOpenUrl(HINTERNET*,LPCTSTR,LPCTSTR,size_t,size_t,size_t);
+  HINTERNET InternetOpenUrl(HINTERNET*,LPCTSTR,LPCTSTR,size_t,size_t,size_t,const maps*);
 
   int processDownloads(HINTERNET*);
