Index: src/org/openstreetmap/josm/gui/GettingStarted.java
===================================================================
--- src/org/openstreetmap/josm/gui/GettingStarted.java	(revision 1432)
+++ src/org/openstreetmap/josm/gui/GettingStarted.java	(working copy)
@@ -4,8 +4,15 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
 import java.io.IOException;
+import java.io.Writer;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Callable;
@@ -50,7 +57,12 @@
             }
         }
     }
-
+    
+    /**
+     * This class encapsulates the "reading URL" task and can be executed in background and in
+     * parallel. Since the MOTD is many separate pages this speeds things up quite a lot. If no
+     * localized version is available, it automatically falls back to the international one.
+     */
     public class readMOTD implements Callable<String> {
         private boolean isLocalized;
         private boolean isHelp;
@@ -58,14 +70,26 @@
         private String urlIntl;
         private String urlBase;
 
-        readMOTD(boolean isLocalized, String urlBase, String urlLoc, String urlIntl, boolean isHelp) {
-          this.isLocalized = isLocalized;
-          this.urlBase = urlBase;
-          this.urlLoc = urlLoc;
-          this.urlIntl = urlIntl;
-          this.isHelp = isHelp;
+        /**
+         * Read a MOTD page
+         * @param isLocalized If true, tries to get localized version as defined in urlLoc
+         * @param urlBase Base URL (i.e. http://www.openstreetmap.de/wiki/)
+         * @param urlLoc Part to append to base URL to receive localized version
+         * @param urlIntl Part to append to base URL to receive international version
+         * @param makeList If true, the URL's contents will be wrapped in a list (<ul><li>)
+         */
+        readMOTD(boolean isLocalized, String urlBase, String urlLoc, String urlIntl, boolean makeList) {
+            this.isLocalized = isLocalized;
+            this.urlBase = urlBase;
+            this.urlLoc = urlLoc;
+            this.urlIntl = urlIntl;
+            this.isHelp = makeList;
         }
-
+        
+        /*
+         * Does the actual work
+         * @see java.util.concurrent.Callable#call()
+         */
         public String call() {
             WikiReader wr = new WikiReader(urlBase);
             String content = "";
@@ -80,13 +104,15 @@
                     if(isHelp)
                         content += message;
                     else
-                        content += "<ul><li>"+ message.substring(8).replaceAll("\n *\\* +","</li><li>")+"</li></ul>";
+                        content += "<ul><li>"+ message.substring(8)
+                                        .replaceAll("\n *\\* +","</li><li>")+"</li></ul>";
             } catch (IOException ioe) {
                 try {
                     if(isHelp)
                         content += wr.read(urlIntl);
                     else
-                        content += "<ul><li>"+wr.read(urlIntl).substring(8).replaceAll("\n *\\* +","</li><li>")+"</li></ul>";
+                        content += "<ul><li>"+wr.read(urlIntl).substring(8)
+                                        .replaceAll("\n *\\* +","</li><li>")+"</li></ul>";
                 } catch (IOException ioe2) {
                 }
             }
@@ -94,9 +120,24 @@
             return content;
         }
     }
-
+    
+    /**
+     * This is where the MOTD will be cached
+     */
+    final static private File cacheDir = new File(Main.pref.getPreferencesDir(), "motd.html");
+    
+    /**
+     * Grabs current MOTD from cache or webpage and parses, then caches it.
+     */
     private void assignContent() {
-        if (content.length() > 0 && Main.pref.getBoolean("help.displaymotd", true)) return;
+        if (content.length() > 0 || !Main.pref.getBoolean("motd.display", true)) return;
+        
+        int myVersion = AboutAction.getVersionNumber();
+        String languageCode = Main.getLanguageCodeU();
+        
+        // Try loading it from cache and quit if successful
+        if(loadFromDisk(myVersion))
+            return;
 
         String baseurl = Main.pref.get("help.baseurl", "http://josm.openstreetmap.de");
         WikiReader wr = new WikiReader(baseurl);
@@ -111,9 +152,6 @@
                 ")</h2>";
         }
 
-        int myVersion = AboutAction.getVersionNumber();
-        String languageCode = Main.getLanguageCodeU();
-
         // Finds wiki links like (underscores inserted for readability): [wiki:LANGCODE:messageoftheday_CONDITON_REVISION LANGCODE]
         // Langcode usually consists of two letters describing the language and may be omitted
         // Condition may be one of the following: >  <  <=  =>
@@ -174,25 +212,96 @@
             linkContent.add(slave.submit(new readMOTD(isLocalized, baseurl, urlLoc, urlIntl, isHelp)));
         }
 
-        for(int i=0; i < linkContent.size(); i++) {
+        linkContent.add(slave.submit(new readMOTD(false, baseurl, "", baseurl + "/latest?format=txt", true)));
+
+        for(int i=0; i < linkContent.size()-1; i++) {
             try {
                 content += linkContent.get(i).get();
             } catch (Exception e) {}
         }
         
+        String version = "<div style=\"text-align:right;font-weight:normal;font-size:small\">";
+        try {
+            String v = linkContent.get(linkContent.size()-1).get().trim().substring(6);
+            version += tr("(Current version: {0}. Your version: {1})", v, myVersion);
+        } catch(Exception e) {}
+        version += "</div>";
+        
         linkContent.clear();
         try {
             slave.shutdown(); 
         } catch(SecurityException x) {}
         
-
         content = "<html>\n"+
             styles +
-            "<h1>JOSM - " + tr("Java OpenStreetMap Editor") + "</h1>\n"+
-            content+"\n"+
+            "<h1>JOSM - " + tr("Java OpenStreetMap Editor") + "</h1>"+
+            content.replace("</html>", "")+
+            version+
             "</html>";
+        
+        saveToDisk(myVersion);
     }
+    
+    /**
+     * Tries to load cached MOTD from disk if the JOSM version is still the same and the last update
+     * is younger than motd.updateinterval milliseconds (default: 24 hours).
+     * 
+     * @param myVersion Currently running version
+     * @return false if update is required, true if cache was valid.
+     */
+    private boolean loadFromDisk(int myVersion) {
+        if(Main.pref.getInteger("motd.lastversion", 0) != myVersion)
+            return false;
+        if(Long.parseLong(Main.pref.get("motd.lastupdate", "0"))
+            + Main.pref.getInteger("motd.updateinterval", 24*60*60*1000)
+                < new Date().getTime())
+            return false;
 
+        StringBuilder c = new StringBuilder();
+        try {
+            BufferedReader input =  new BufferedReader(new FileReader(cacheDir));
+            try {
+                String line = null; 
+                while (( line = input.readLine()) != null){
+                    c.append(line);
+                    c.append("\n");
+                }
+            } finally {
+                input.close();
+            }
+        }
+        catch (IOException ex){
+            ex.printStackTrace();
+        }
+        
+        content = c.toString();
+        return content.length() > 0;
+    }
+
+    /**
+     * Saves current MOTD to disk and updates "last update" variables
+     * @param myVersion currently running version
+     */
+    private void saveToDisk(int myVersion) {
+        try {
+            Writer output = new BufferedWriter(new FileWriter(
+                    new File(Main.pref.getPreferencesDir(), "motd.html")));
+            try {
+                output.write(content);
+                Main.pref.put("motd.lastupdate", Long.toString(new Date().getTime()));
+                Main.pref.putInteger("motd.lastversion", myVersion);
+            } finally {
+                output.close();
+            }
+        } catch(Exception e) {
+            Main.pref.putInteger("motd.lastupdate", 0);
+        }
+    }
+
+    /**
+     * Initializes getting the MOTD as well as enabling the FileDrop Listener.
+     * Displays a message while the MOTD is downloading.
+     */
     public GettingStarted() {
         super(new BorderLayout());
         final LinkGeneral lg = new LinkGeneral(
