![](/img/trans.png)
[英]ESP32: How would I serve an image from SPIFFS(flash memory) to a softAPI server?
[英]ESP32 Asynch Web Server is slow in port 80 serveStatic from SPIFFS get slow web server
经过一番尝试后,我发现了问题。
不,错误不在于端口 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.