Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java	(revision 13420)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java	(revision 13426)
@@ -18,5 +18,4 @@
 import javax.swing.JOptionPane;
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.coor.EastNorth;
 
 public class CacheControl implements Runnable {
@@ -112,41 +111,6 @@
             FileInputStream fis = new FileInputStream(file);
             ObjectInputStream ois = new ObjectInputStream(fis);
-            int sfv = ois.readInt();
-            if (sfv != wmsLayer.serializeFormatVersion) {
-                JOptionPane.showMessageDialog(Main.parent, tr("Unsupported WMS file version; found {0}, expected {1}",
-                        sfv, wmsLayer.serializeFormatVersion), tr("Cache Format Error"), JOptionPane.ERROR_MESSAGE);
+            if (wmsLayer.read(ois, currentLambertZone) == false)
                 return false;
-            }
-            wmsLayer.setLocation((String) ois.readObject());
-            wmsLayer.setCodeCommune((String) ois.readObject());
-            wmsLayer.lambertZone = ois.readInt();
-            wmsLayer.setRaster(ois.readBoolean());
-            wmsLayer.setRasterMin((EastNorth) ois.readObject());
-            wmsLayer.setRasterCenter((EastNorth) ois.readObject());
-            wmsLayer.setRasterRatio(ois.readDouble());
-            if (wmsLayer.lambertZone != currentLambertZone) {
-                JOptionPane.showMessageDialog(Main.parent, tr("Lambert zone {0} in cache "+
-                        " incompatible with current Lambert zone {1}",
-                        wmsLayer.lambertZone+1, currentLambertZone), tr("Cache Lambert Zone Error"), JOptionPane.ERROR_MESSAGE);
-                return false;
-            }
-            boolean EOF = false;
-            try {
-                while (!EOF) {
-                    GeorefImage newImage = (GeorefImage) ois.readObject();
-                    for (GeorefImage img : wmsLayer.images) {
-                        if (CadastrePlugin.backgroundTransparent) {
-                            if (img.overlap(newImage))
-                                // mask overlapping zone in already grabbed image
-                                img.withdraw(newImage);
-                            else
-                                // mask overlapping zone in new image only when
-                                // new image covers completely the existing image
-                                newImage.withdraw(img);
-                        }
-                    }
-                    wmsLayer.images.add(newImage);
-                }
-            } catch (EOFException e) {}
             ois.close();
             fis.close();
@@ -155,4 +119,5 @@
             JOptionPane
                     .showMessageDialog(Main.parent, tr("Error loading file"), tr("Error"), JOptionPane.ERROR_MESSAGE);
+            return false;
         }
         return true;
@@ -205,15 +170,5 @@
                         ObjectOutputStream oos = new ObjectOutputStream(
                                 new BufferedOutputStream(new FileOutputStream(file)));
-                        oos.writeInt(wmsLayer.serializeFormatVersion);
-                        oos.writeObject(wmsLayer.getLocation());
-                        oos.writeObject(wmsLayer.getCodeCommune());
-                        oos.writeInt(wmsLayer.lambertZone);
-                        oos.writeBoolean(wmsLayer.isRaster());
-                        oos.writeObject(wmsLayer.getRasterMin());
-                        oos.writeObject(wmsLayer.getRasterCenter());
-                        oos.writeDouble(wmsLayer.getRasterRatio());
-                        for (GeorefImage img : images) {
-                            oos.writeObject(img);
-                        }
+                        wmsLayer.write(oos, images);
                         oos.close();
                     }
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 13420)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 13426)
@@ -18,4 +18,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.tools.GBC;
@@ -38,4 +39,6 @@
     final String c0ptionListStart = "<option value=\"";
     final String cOptionListEnd = "</option>";
+    final String cBBoxCommunStart = "new GeoBox(";
+    final String cBBoxCommunEnd = ")";
     
     final String cInterfaceVector = "afficherCarteCommune.do";
@@ -310,4 +313,46 @@
     }
     
+    public EastNorthBound retrieveCommuneBBox() throws IOException {
+        if (interfaceRef == null)
+            return null;
+        String ln = null;
+        String line = null;
+        // send GET opening normally the small window with the commune overview
+        String content = baseURL + "/scpc/" + interfaceRef;
+        content += "&dontSaveLastForward&keepVolatileSession=";
+        searchFormURL = new URL(content);
+        System.out.println("HEAD:"+content);
+        urlConn = (HttpURLConnection)searchFormURL.openConnection();
+        urlConn.setRequestMethod("GET");
+        setCookie();
+        urlConn.connect();
+        if (urlConn.getResponseCode() != HttpURLConnection.HTTP_OK) {
+            throw (IOException) new IOException("Cannot get Cadastre response.");
+        }
+        BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
+        while ((ln = in.readLine()) != null) {
+            line += ln;
+        }
+        in.close();
+        urlConn.disconnect();
+        return parseBBoxCommune(line);
+    }
+    
+    private EastNorthBound parseBBoxCommune(String input) {
+        if (input.indexOf(cBBoxCommunStart) != -1) {
+            input = input.substring(input.indexOf(cBBoxCommunStart));
+            int i = input.indexOf(",");
+            double minx = Double.parseDouble(input.substring(cBBoxCommunStart.length(), i));
+            int j = input.indexOf(",", i+1);
+            double miny = Double.parseDouble(input.substring(i+1, j));
+            int k = input.indexOf(",", j+1);
+            double maxx = Double.parseDouble(input.substring(j+1, k));
+            int l = input.indexOf(cBBoxCommunEnd, k+1);
+            double maxy = Double.parseDouble(input.substring(k+1, l));
+            return new EastNorthBound(new EastNorth(minx,miny), new EastNorth(maxx,maxy));
+        }
+        return null;
+    }
+    
     private void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException {
         if (Main.map != null) {
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 13420)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 13426)
@@ -64,4 +64,5 @@
  *                 - minor fixes due to changes in JOSM core classes
  *                 - first draft of raster image support 
+ * 0.9 draft       - grab vectorized full commune bbox and save it in cache
  */
 public class CadastrePlugin extends Plugin {
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSTask.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSTask.java	(revision 13420)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSTask.java	(revision 13426)
@@ -29,12 +29,18 @@
         try {
             if (grabber.getWmsInterface().retrieveInterface(wmsLayer)) {
-                if (wmsLayer.isRaster() && wmsLayer.images.isEmpty())
-                    wmsLayer.setRasterBounds(bounds);
-                if (CacheControl.cacheEnabled && wmsLayer.images.isEmpty()) {
-                    // images loaded from cache
-                    if (wmsLayer.getCacheControl().loadCacheIfExist()) {
-                        Main.map.mapView.repaint();
-                        return;
+                if (wmsLayer.images.isEmpty()) {
+                    // first time we grab an image for this layer
+                    if (CacheControl.cacheEnabled) {
+                        if (wmsLayer.getCacheControl().loadCacheIfExist()) {
+                            Main.map.mapView.repaint();
+                            return;
+                        }
                     }
+                    if (wmsLayer.isRaster())
+                        // set raster image commune bounding box based on current view (before adjustment) 
+                        wmsLayer.setRasterBounds(bounds);
+                    else
+                        // set vectorized commune bounding box by opening the standard web window
+                        wmsLayer.setCommuneBBox( grabber.getWmsInterface().retrieveCommuneBBox());
                 }
                 // grab new images from wms server into active layer
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/EastNorthBound.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/EastNorthBound.java	(revision 13426)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/EastNorthBound.java	(revision 13426)
@@ -0,0 +1,20 @@
+package cadastre_fr;
+
+import java.io.Serializable;
+
+import org.openstreetmap.josm.data.coor.EastNorth;
+
+public class EastNorthBound implements Serializable {
+
+    private static final long serialVersionUID = 8451650309216472069L;
+    
+    public EastNorth min, max;
+    public EastNorthBound(EastNorth min, EastNorth max) {
+        this.min = min;
+        this.max = max;
+    }
+    @Override public String toString() {
+        return "EastNorthBound[" + min.east() + "," + min.north() + "," + max.east() + "," + max.north() + "]";
+    }
+}
+
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java	(revision 13420)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java	(revision 13426)
@@ -60,6 +60,6 @@
             // create layer and load cache
             WMSLayer wmsLayer = new WMSLayer("", "", Integer.parseInt(ext)-1);
-            wmsLayer.getCacheControl().loadCache(file, Lambert.layoutZone);
-            Main.main.addLayer(wmsLayer);
+            if (wmsLayer.getCacheControl().loadCache(file, Lambert.layoutZone))
+                Main.main.addLayer(wmsLayer);
         }
         
Index: applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
===================================================================
--- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 13420)
+++ applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 13426)
@@ -9,4 +9,5 @@
 import java.awt.event.ActionEvent;
 import java.awt.image.BufferedImage;
+import java.io.EOFException;
 import java.io.File;
 import java.io.FileInputStream;
@@ -45,15 +46,4 @@
 public class WMSLayer extends Layer {
 
-    public class EastNorthBound {
-        public EastNorth min, max;
-        public EastNorthBound(EastNorth min, EastNorth max) {
-            this.min = min;
-            this.max = max;
-        }
-        @Override public String toString() {
-            return "EastNorthBound[" + min.east() + "," + min.north() + "," + max.east() + "," + max.north() + "]";
-        }
-    }
-    
     Component[] component = null;  
 
@@ -65,5 +55,5 @@
     protected ArrayList<GeorefImage> images = new ArrayList<GeorefImage>();
     
-    protected final int serializeFormatVersion = 1;
+    protected final int serializeFormatVersion = 2;
     
     private ArrayList<EastNorthBound> dividedBbox = new ArrayList<EastNorthBound>();
@@ -74,4 +64,6 @@
 
     private String codeCommune = "";
+    
+    private EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0,0), new EastNorth(0,0));
     
     private boolean isRaster = false;
@@ -492,4 +484,80 @@
         }
     }
+    
+    /**
+     * Called by CacheControl when a new cache file is created on disk
+     * @param oos
+     * @throws IOException
+     */
+    public void write(ObjectOutputStream oos, ArrayList<GeorefImage> imgs) throws IOException {
+        oos.writeInt(this.serializeFormatVersion);
+        oos.writeObject(this.location);
+        oos.writeObject(this.codeCommune);
+        oos.writeInt(this.lambertZone);
+        oos.writeBoolean(this.isRaster);
+        if (this.isRaster) { 
+            oos.writeObject(this.rasterMin);
+            oos.writeObject(this.rasterCenter);
+            oos.writeDouble(this.rasterRatio);
+        } else {
+            oos.writeObject(this.communeBBox);
+        }
+        for (GeorefImage img : imgs) {
+            oos.writeObject(img);
+        }
+    }
+    
+    /**
+     * Called by CacheControl when a cache file is read from disk
+     * @param ois
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    public boolean read(ObjectInputStream ois, int currentLambertZone) throws IOException, ClassNotFoundException {
+        int sfv = ois.readInt();
+        if (sfv != this.serializeFormatVersion) {
+            JOptionPane.showMessageDialog(Main.parent, tr("Unsupported cache file version; found {0}, expected {1}\nCreate a new one.",
+                    sfv, this.serializeFormatVersion), tr("Cache Format Error"), JOptionPane.ERROR_MESSAGE);
+            return false;
+        }
+        this.setLocation((String) ois.readObject());
+        this.setCodeCommune((String) ois.readObject());
+        this.lambertZone = ois.readInt();
+        this.isRaster = ois.readBoolean();
+        if (this.isRaster) { 
+            this.rasterMin = (EastNorth) ois.readObject();
+            this.rasterCenter = (EastNorth) ois.readObject();
+            this.rasterRatio = ois.readDouble();
+        } else {
+            this.communeBBox = (EastNorthBound) ois.readObject();
+        }
+        if (this.lambertZone != currentLambertZone) {
+            JOptionPane.showMessageDialog(Main.parent, tr("Lambert zone {0} in cache "+
+                    " incompatible with current Lambert zone {1}",
+                    this.lambertZone+1, currentLambertZone), tr("Cache Lambert Zone Error"), JOptionPane.ERROR_MESSAGE);
+            return false;
+        }
+        boolean EOF = false;
+        try {
+            while (!EOF) {
+                GeorefImage newImage = (GeorefImage) ois.readObject();
+                for (GeorefImage img : this.images) {
+                    if (CadastrePlugin.backgroundTransparent) {
+                        if (img.overlap(newImage))
+                            // mask overlapping zone in already grabbed image
+                            img.withdraw(newImage);
+                        else
+                            // mask overlapping zone in new image only when
+                            // new image covers completely the existing image
+                            newImage.withdraw(img);
+                    }
+                }
+                this.images.add(newImage);
+            }
+        } catch (EOFException ex) {
+            // expected exception when all images are read
+        }
+        return true;
+    }
 
     public double getRasterRatio() {
@@ -509,3 +577,11 @@
     }
 
+    public EastNorthBound getCommuneBBox() {
+        return communeBBox;
+    }
+
+    public void setCommuneBBox(EastNorthBound entireCommune) {
+        this.communeBBox = entireCommune;
+    }
+
 }
