繁体   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