diff --git a/lib/url.c b/lib/url.c
index 10e37ec67f..ed06dfd9ea 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -678,28 +678,30 @@ static bool conn_maxage(struct Curl_easy *data,
                         struct connectdata *conn,
                         struct curltime now)
 {
-  timediff_t idletime, lifetime;
+  if(data->set.maxage_conn) {
+    timediff_t idletime = curlx_timediff(now, conn->lastused);
 
-  idletime = curlx_timediff(now, conn->lastused);
-  idletime /= 1000; /* integer seconds is fine */
-
-  if(idletime > data->set.maxage_conn) {
-    infof(data, "Too old connection (%" FMT_TIMEDIFF_T
-          " seconds idle), disconnect it", idletime);
-    return TRUE;
+    if((idletime / 1000) > data->set.maxage_conn) {
+      infof(data, "Too old connection (%" FMT_TIMEDIFF_T
+            " ms idle), disconnect it", idletime);
+      return TRUE;
+    }
+    DEBUGF(infof(data, "connection has been idle for %" FMT_TIMEDIFF_T
+           " ms (max idle %ld sec)", idletime, data->set.maxage_conn));
   }
 
-  lifetime = curlx_timediff(now, conn->created);
-  lifetime /= 1000; /* integer seconds is fine */
-
-  if(data->set.maxlifetime_conn && lifetime > data->set.maxlifetime_conn) {
-    infof(data,
-          "Too old connection (%" FMT_TIMEDIFF_T
-          " seconds since creation), disconnect it", lifetime);
-    return TRUE;
+  if(data->set.maxlifetime_conn) {
+    timediff_t lifetime = curlx_timediff(now, conn->created);
+    if((lifetime / 1000) > data->set.maxlifetime_conn) {
+      infof(data,
+            "Too old connection (%" FMT_TIMEDIFF_T
+            " ms since creation), disconnect it", lifetime);
+      return TRUE;
+    }
+    DEBUGF(infof(data, "connection age is %" FMT_TIMEDIFF_T
+           " ms (max %ld sec)", lifetime, data->set.maxlifetime_conn));
   }
 
-
   return FALSE;
 }
 

