diff --git a/Makefile b/Makefile
index 9ee5559bcdb2552eb93c50a1fb267fbec9659db1..29b5d44503880e7973e146eaee6dc54176243038 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ BINDIR ?= /usr/sbin
 
 PROG_CFLAGS = $(CFLAGS) -DHAS_UBUS -Wall -Werror -fstrict-aliasing -ggdb
 #PROG_CFLAGS += -DDONOT_CREATE_AFFILIATED_IFACE_OBJECT
+#PROG_CFLAGS += -DWIFI_CACHE_SCANRESULTS
 CFLAGS += -Wno-address-of-packed-member
 PROG_LDFLAGS = $(LDFLAGS)
 PROG_LIBS += -lssl -lcrypto -leasy -lwifiutils -lwifi-7 -lm -ldl
diff --git a/wifimngr.c b/wifimngr.c
index df867db360a63f4f115e5ae1af577857da98691c..dbdc5f4e5f7200c67cd2e811fcb239205b96485e 100644
--- a/wifimngr.c
+++ b/wifimngr.c
@@ -2695,25 +2695,6 @@ struct wifimngr_channel *wifimngr_device_lookup_freq(struct wifimngr_device *wde
 	return NULL;
 }
 
-int wifimngr_update_scanresults(struct wifimngr_device *wdev, int num_scanres,
-				struct wifi_bss *scanres)
-{
-	int i;
-
-	for (i = 0; i < num_scanres; i++) {
-		struct wifimngr_channel *ch =
-			wifimngr_device_lookup_channel(wdev, scanres[i].channel);
-
-		if (ch) {
-			memcpy(&ch->scanres[ch->num_scanres++], &scanres[i],
-			       sizeof(struct wifi_bss));
-			time(&ch->scanres_ts);
-		}
-	}
-
-	return 0;
-}
-
 static void wl_scanresult_print(struct blob_buf *bb, void *buf, bool detail)
 {
 	struct wifi_bss *b = (struct wifi_bss *)buf;
@@ -2786,7 +2767,7 @@ int wl_scanresults(struct ubus_context *ctx, struct ubus_object *obj,
 	bool cache = false;
 	const char *radio;
 	void *a, *t;
-	int i, j;
+	int i;
 
 
 	blobmsg_parse(wl_scanres_policy, __SCANRES_MAX, tb, blob_data(msg),
@@ -2822,11 +2803,28 @@ int wl_scanresults(struct ubus_context *ctx, struct ubus_object *obj,
 		return UBUS_STATUS_OK;
 	}
 
+	blob_buf_init(&bb, 0);
+	a = blobmsg_open_array(&bb, "accesspoints");
+
+#if WIFI_CACHE_SCANRESULTS
 	if (tb[SCANRES_CACHE])
 		cache = blobmsg_get_bool(tb[SCANRES_CACHE]);
 
-	blob_buf_init(&bb, 0);
-	a = blobmsg_open_array(&bb, "accesspoints");
+	if (cache) {
+		for (i = 0; i < wdev->num_ch; i++) {
+			if (!wdev->ch[i].num_scanres)
+				continue;
+
+			for (int j = 0; j < wdev->ch[i].num_scanres; j++) {
+				t = blobmsg_open_table(&bb, "");
+				wl_scanresult_print(&bb, &wdev->ch[i].scanres[j], detail);
+				blobmsg_add_u32(&bb, "elapsed", difftime(time(NULL), wdev->ch[i].scanres_ts));
+				blobmsg_close_table(&bb, t);
+			}
+		}
+	}
+#endif /* WIFI_CACHE_SCANRESULTS */
+
 	if (!cache) {
 		int ret;
 
@@ -2839,18 +2837,6 @@ int wl_scanresults(struct ubus_context *ctx, struct ubus_object *obj,
 			wl_scanresult_print(&bb, &bsss[i], detail);
 			blobmsg_close_table(&bb, t);
 		}
-	} else {
-		for (i = 0; i < wdev->num_ch; i++) {
-			if (!wdev->ch[i].num_scanres)
-				continue;
-
-			for (j = 0; j < wdev->ch[i].num_scanres; j++) {
-				t = blobmsg_open_table(&bb, "");
-				wl_scanresult_print(&bb, &wdev->ch[i].scanres[j], detail);
-				blobmsg_add_u32(&bb, "elapsed", difftime(time(NULL), wdev->ch[i].scanres_ts));
-				blobmsg_close_table(&bb, t);
-			}
-		}
 	}
 	blobmsg_close_array(&bb, a);
 
@@ -5907,6 +5893,48 @@ int wifimngr_reconfig(struct wifimngr *w)
 	return 0;
 }
 
+#ifdef WIFI_CACHE_SCANRESULTS
+int wifimngr_update_scanresults(struct wifimngr_device *wdev, int num_scanres,
+				struct wifi_bss *scanres)
+{
+	int i;
+
+	for (i = 0; i < num_scanres; i++) {
+		struct wifimngr_channel *ch =
+			wifimngr_device_lookup_channel(wdev, scanres[i].channel);
+
+		if (ch) {
+			memcpy(&ch->scanres[ch->num_scanres++], &scanres[i],
+			       sizeof(struct wifi_bss));
+			time(&ch->scanres_ts);
+		}
+	}
+
+	return 0;
+}
+
+int wifimngr_get_initial_scanresults(struct wifimngr *w)
+{
+	int i;
+
+	for (i = 0; i < w->num_wifi_device; i++) {
+		struct wifi_bss scanres[NUM_SCANRES] = {0};
+		int num = ARRAY_SIZE(scanres);
+		int ret;
+
+		wifimngr_device_init_channels(&w->wdev[i]);
+
+		ret = wifi_get_band_scan_results(w->wdev[i].phy,
+						 w->wdev[i].band,
+						 scanres,
+						 &num);
+		if (!ret && num > 0)
+			wifimngr_update_scanresults(&w->wdev[i], num, scanres);
+	}
+
+	return 0;
+}
+
 /* scan event data */
 enum scan_event_data_attr {
 	SCAN_EVENT_ATTR_FREQ,
@@ -6000,6 +6028,7 @@ int wifimngr_update_scanresults_cache(struct wifimngr_device *wdev, int sz,
 
 	return 0;
 }
+#endif /* WIFI_CACHE_SCANRESULTS */
 
 int wifimngr_device_init_channels(struct wifimngr_device *wdev)
 {
@@ -6034,28 +6063,6 @@ int wifimngr_device_init_channels(struct wifimngr_device *wdev)
 	return 0;
 }
 
-int wifimngr_get_initial_scanresults(struct wifimngr *w)
-{
-	int i;
-
-	for (i = 0; i < w->num_wifi_device; i++) {
-		struct wifi_bss scanres[NUM_SCANRES] = {0};
-		int num = ARRAY_SIZE(scanres);
-		int ret;
-
-		wifimngr_device_init_channels(&w->wdev[i]);
-
-		ret = wifi_get_band_scan_results(w->wdev[i].phy,
-						 w->wdev[i].band,
-						 scanres,
-						 &num);
-		if (!ret && num > 0)
-			wifimngr_update_scanresults(&w->wdev[i], num, scanres);
-	}
-
-	return 0;
-}
-
 int wl_sta_ratings_recalc(void *libctx)
 {
 	struct radio_entry radios[4] = {0};
@@ -6181,8 +6188,9 @@ int wifimngr_init(struct wifimngr **w, struct wifimngr_cmdline_opts *opts)
 		goto out_error;
 	}
 
+#ifdef WIFI_CACHE_SCANRESULTS
 	wifimngr_get_initial_scanresults(wm);
-
+#endif
 	uloop_timeout_set(&wm->hbtimer, 1000);
 	return 0;
 
diff --git a/wifimngr.h b/wifimngr.h
index f68477b4f5829eadb4e83830b6d3e91dcb8f4231..7fe4188758e41e884d5c44cfe3dba7d90e05295c 100644
--- a/wifimngr.h
+++ b/wifimngr.h
@@ -52,10 +52,12 @@ struct wifimngr_channel {
 	uint32_t channel;		/* 20MHz ctrl-channel */
 	uint32_t freq;			/* frequency in MHz */
 
+#ifdef WIFI_CACHE_SCANRESULTS 
 	/* cached scanresults from latest scan */
 	time_t scanres_ts;
 	int num_scanres;
 	struct wifi_bss scanres[MAX_NUM_PER_CHANNEL_SCANRES];
+#endif
 };
 
 struct wifimngr_device {
diff --git a/wifimngr_event.c b/wifimngr_event.c
index 86818f00f014812715e9ae7d643307828c138921..e47725677edfff2bb16fcd1bd734e9e342dd3826 100644
--- a/wifimngr_event.c
+++ b/wifimngr_event.c
@@ -103,7 +103,7 @@ int wifimngr_event_cb(struct event_struct *e)
 				 WIFI_RADIO_OBJECT, e->ifname, evtype);
 		}
 		wifimngr_ubus_event(w->ubus_ctx, evtbuf);
-
+#ifdef WIFI_CACHE_SCANRESULTS
 		if (resp->type == WIFI_EVENT_SCAN_END) {
 			struct wifimngr_device *wdev;
 
@@ -114,6 +114,7 @@ int wifimngr_event_cb(struct event_struct *e)
 								  (char *)resp->data);
 			}
 		}
+#endif
 		break;
 	case WIFI_EVENT_SCAN_ABORT:
 		snprintf(evtbuf, MAX_EVENT_RESPONSE_LEN - 1,