簡體   English   中英

ESP32 異步 Web 服務器在端口 80 上很慢 來自 SPIFFS 的 serverStatic 變慢 web 服務器

[英]ESP32 Asynch Web Server is slow in port 80 serveStatic from SPIFFS get slow web server

我的 esp32 使用 async we server 時遇到問題。

我有兩台服務器運行異步 web 服務器庫,我不知道為什么,端口 80 很慢,看看:

答案是每台服務器的代碼相同,只是端口更改。

請求端口 80:

80端口請求:

向端口 4567 請求:

非 80 端口請求

為什么端口 80 慢了 10 倍??? 我在考慮 Chrome,但 olso postman 和 firefox 也出現了同樣的問題。

任何想法?

經過一番嘗試后,我發現了問題。

不,錯誤不在於端口 80、瀏覽器或 esp32 與用戶之間的任何其他 faboulus 事物。

  server.serveStatic("/assets/", SPIFFS, "/assets/").setCacheControl("max-age=31536000");

我使用這個 function 來提供帶有cahce的頁面,不完全是,function 是這樣的:

  server.serveStatic("/", SPIFFS, "/").setCacheControl("max-age=31536000");

我不知道確切的原因,但之后的速度非常緩慢。

在移動我之前的所有“api”端點之后,響應速度比其他端口中的其他服務器更快。

此外使用:

server.serveStatic("/", SPIFFS, "/").setCacheControl("max-age=31536000");

don't set automatically the cache header of the web pages stored in the "/" folder, cause there's a server.on listenging for that url, the cache header is applyed only if you are going to get the file.

前任:

http:/espipaddres/page.html ->將有緩存 header

http:/espipaddres/page

  server.on("/page", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(SPIFFS, "/page.html", "text/html");
  });

不會有緩存 header

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM