Index: /trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 4812)
+++ /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 4813)
@@ -82,4 +82,8 @@
      */
     private File preferencesDirFile = null;
+    /**
+     * Internal storage for the cache directory.
+     */
+    private File cacheDirFile = null;
 
     /**
@@ -271,15 +275,27 @@
     
     public File getCacheDirectory() {
-        File cache = new File(getPreferencesDirFile(), "cache");
-        if (!cache.exists() && !cache.mkdirs()) {
-            System.err.println(tr("Warning: Failed to create missing cache directory: {0}", cache.getAbsoluteFile()));
+        if (cacheDirFile != null)
+            return cacheDirFile;
+        String path = System.getProperty("josm.cache");
+        if (path != null) {
+            cacheDirFile = new File(path).getAbsoluteFile();
+        } else {
+            path = Main.pref.get("cache.folder", null);
+            if (path != null) {
+                cacheDirFile = new File(path);
+            } else {
+                cacheDirFile = new File(getPreferencesDirFile(), "cache");
+            }
+        }
+        if (!cacheDirFile.exists() && !cacheDirFile.mkdirs()) {
+            System.err.println(tr("Warning: Failed to create missing cache directory: {0}", cacheDirFile.getAbsoluteFile()));
             JOptionPane.showMessageDialog(
                     Main.parent,
-                    tr("<html>Failed to create missing cache directory: {0}</html>",cache.getAbsoluteFile()),
+                    tr("<html>Failed to create missing cache directory: {0}</html>", cacheDirFile.getAbsoluteFile()),
                     tr("Error"),
                     JOptionPane.ERROR_MESSAGE
             );
         }
-        return cache;
+        return cacheDirFile;
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/imagery/WmsCache.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/WmsCache.java	(revision 4812)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/WmsCache.java	(revision 4813)
@@ -53,5 +53,5 @@
     //TODO Do loading from partial cache and downloading at the same time, don't wait for partical cache to load
 
-    private static final StringProperty PROP_CACHE_PATH = new StringProperty("imagery.wms-cache.path", "wms-cache");
+    private static final StringProperty PROP_CACHE_PATH = new StringProperty("imagery.wms-cache.path", new File(Main.pref.getCacheDirectory(), "wms").getPath());
     private static final String INDEX_FILENAME = "index.xml";
     private static final String LAYERS_INDEX_FILENAME = "layers.properties";
@@ -100,5 +100,5 @@
         if (!(cPath.startsWith("/") || cPath.startsWith(":/",1))) {
             //Not an absolute path
-            cPath = Main.pref.getPreferencesDir() + cPath;
+            cPath = Main.pref.getCacheDirectory() + cPath;
         }
         return cPath;
