![](/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.