forked from tbnobody/OpenDTU
-
-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Labels
Description
What happened?
Files are not cached any more since #1897 added Cache-Control: public, must-revalidate
and effectively disabled the browser Cache.
The above fix was introduced in #1898
To Reproduce Bug
Use the CURL commands described in #1897 (comment) and following comments to verify using the command line.
Expected Behavior
@schlimmchen as requested I have created this issue with the following points:
- Static files should have the
Cache-Control: public, max-age=2678400
which would cache for 31 days. - In case of static files like
/js/app.js.gz
and css files we should keep precalculated md5sums of the files somewhere to make calculation less effort for the ESP32AsyncWebServer. I do not know whether you would already hash it together with the githash of the current OpenDTU-OnBattery firmware version. - I think about language files, as well as
pin_mapping.json
andconfig.json
, which may persist an OpenDTU update and therefor we would need the md5sum of the file to calculate the md5sum combined with the githash. HEAD
should verify theIf-None-Match
request header with theETag
for the resource being requested.- So we will have to make some sanitation, e.g. all lowercase and remove quotes if existing.
- Even if we send the
ETag
with double quotes we can't rely that every browser sends back the value in double quotes. We have seen several browsers which are NOT returning theETag
in double quotes (for example the OEM Samsung browser) which makes the server comparison more difficult. - Don't rely on that you will receive the HTTP Header field exactly as
If-None-Match
, be prepared to get it in small or capital letters also.
- Even if we send the
GET
on static files should also verify theIf-None-Match
request header with theETag
for the resource.- In case they match the response should be
HTTP/1.1 304 Not Modified
if (server.header("If-None-Match") == eTagCode) {
server.send(304);
return true;
}
Install Method
Pre-Compiled binary from GitHub releases
What git-hash/version of OpenDTU-OnBattery?
What firmware variant (PIO Environment)?
generic_esp32s3_usb
Relevant log/trace output
Anything else?
Thanks for considering this to fix this issue.
As mentioned in the other issue this was a very quick and graspable overview as it included some pictures of the communication flow.
https://werner.rothschopf.net/microcontroller/202011_arduino_webserver_caching_en.htm
Please confirm the following
- I believe this issue is a bug that affects all users of OpenDTU-OnBattery, not something specific to my installation.
- I have already searched for relevant existing issues and discussions before opening this report.
- I have updated the title field above with a concise description.
- I have double checked that my inverter does not contain a W in the model name (like HMS-xxxW) as they are not supported.
Copilot