mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 19:12:10 +01:00
Improve performance by moving script to a cached file.
All object references not look for cached script file. This eliminates the need to reload the script when simply rendering the page. ESP32 does not need to download this data if the cache already has it. Implemented versioning on the script tags.
This commit is contained in:
parent
f88e02b25c
commit
5ef3e01226
4 changed files with 1577 additions and 1567 deletions
13
Web.cpp
13
Web.cpp
|
|
@ -206,6 +206,19 @@ void Web::begin() {
|
|||
server.streamFile(file, _encoding_html);
|
||||
file.close();
|
||||
});
|
||||
server.on("/index.js", []() {
|
||||
webServer.sendCacheHeaders(604800);
|
||||
webServer.sendCORSHeaders();
|
||||
// Load the index html page from the data directory.
|
||||
Serial.println("Loading file index.js");
|
||||
File file = LittleFS.open("/index.js", "r");
|
||||
if (!file) {
|
||||
Serial.println("Error opening data/index.js");
|
||||
server.send(500, _encoding_text, "Unable to open data/index.js");
|
||||
}
|
||||
server.streamFile(file, "text/javascript");
|
||||
file.close();
|
||||
});
|
||||
server.on("/main.css", []() {
|
||||
webServer.sendCacheHeaders(604800);
|
||||
webServer.sendCORSHeaders();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue