Minimizing calls to web server

This commit is contained in:
Gunnar Skjold
2020-02-18 21:33:41 +01:00
parent 916b5550d9
commit 78e766156d
8 changed files with 43 additions and 27 deletions

View File

@@ -134,6 +134,11 @@ void AmsWebServer::indexHtml() {
String html = String((const __FlashStringHelper*) INDEX_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
html.replace("${data.P}", String(p));
html.replace("${data.PO}", String(po));
html.replace("${display.production}", config->getProductionCapacity() > 0 ? "" : "none");
@@ -186,6 +191,10 @@ void AmsWebServer::configMeterHtml() {
String html = String((const __FlashStringHelper*) CONFIGMETER_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
@@ -216,6 +225,10 @@ void AmsWebServer::configWifiHtml() {
String html = String((const __FlashStringHelper*) CONFIGWIFI_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
@@ -239,6 +252,10 @@ void AmsWebServer::configMqttHtml() {
String html = String((const __FlashStringHelper*) CONFIGMQTT_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
@@ -264,6 +281,10 @@ void AmsWebServer::configWebHtml() {
String html = String((const __FlashStringHelper*) CONFIGWEB_HTML);
html.replace("${version}", VERSION);
if(WiFi.getMode() != WIFI_AP) {
html.replace("boot.css", BOOTSTRAP_URL);
}
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");

View File

@@ -1,6 +1,8 @@
#ifndef _AMSWEBSERVER_h
#define _AMSWEBSERVER_h
#define BOOTSTRAP_URL "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css"
#include <ArduinoJson.h>
#include <MQTT.h>
#include "AmsConfiguration.h"