Index: src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
===================================================================
--- src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(revision 31043)
+++ src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(working copy)
@@ -66,7 +66,7 @@
         } catch (SecurityException e) {
             log.log(Level.WARNING,
                     "Failed to access system property ''java.io.tmpdir'' for security reasons. Exception was: "
-                    + e.toString());
+                            + e.toString());
             throw e; // rethrow
         }
         try {
@@ -248,6 +248,24 @@
                     }
                 }
 
+                // set file modification date to Expires / max-age date but subtract maxCacheFileAge - so
+                // Expires/cache-control headers will be honored
+                Long lng = urlConn.getExpiration();
+                if (lng == null) {
+                    String str = urlConn.getHeaderField("Cache-Control");
+                    if (str != null) {
+                        for (String token: str.split(",")) {
+                            if (token.startsWith("max-age=")) {
+                                lng = Long.parseLong(token.substring(8))+System.currentTimeMillis();
+                            }
+                        }
+                    }
+                }
+                if (lng != null) {
+                    tileFile.setLastModified(lng - maxCacheFileAge);
+                }
+
+
                 loadTileMetadata(tile, urlConn);
                 saveTagsToFile();
 
@@ -295,7 +313,7 @@
                 fileMtime = tileFile.lastModified();
                 if (now - fileMtime > maxAge)
                     return false;
-
+                    
                 if ("no-tile".equals(tile.getValue("tile-info"))) {
                     tile.setError("No tile at this zoom level");
                     if (tileFile.exists()) {
@@ -405,8 +423,8 @@
             File file = getTileFile();
             file.getParentFile().mkdirs();
             try (
-                FileOutputStream f = new FileOutputStream(file)
-            ) {
+                    FileOutputStream f = new FileOutputStream(file)
+                    ) {
                 f.write(rawData);
             } catch (Exception e) {
                 log.log(Level.SEVERE, "Failed to save tile content: {0}", e.getLocalizedMessage());
