-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert caching of Content-Type headers #121831
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
I wasn't expecting the solution to be to revert the caching. I'll take a look this weekend to see what the impact is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than also fix it here, IMO just eliminating the copied code is the better solution as I think the logic for caching it is flawed.
I disagree that the logic for caching it is flawed. The caching is based on observing real world requests and profiling the server. The repeated guess mime type calls show up in the profile which was the original reason for adding the cache.
I agree ignoring the encoding is a problem. That's even more complicated because https://github.com/aio-libs/aiohttp/pull/8485/files#diff-7eeb7201d1ad679d4091189dc43b7a7b843c1b2fc0f0914301addcb25179e6b1L279 seeks to eliminate sending it, but we should fix the cache instead of eliminating it.
https://github.com/aio-libs/aiohttp/pull/8485/files#r1675359145 would eliminate the need to look at encoding, achieve the desired outcome, and lets stdlib mimetypes
handle more of the complexity.
If we went that direction, we could use the MimeTypes object from aiohttp in the future here as well and eliminate most of the duplication.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
This comment was marked as duplicate.
This comment was marked as duplicate.
We can figure out the best approach on the |
As its been a few months since #103281, I have already deleted the profiles from the user that provided them where the issue was discovered. I do remember that they had multiple wall tablets so it should be possible to recreate the data by setting up a few tablets pointing to a dev instance, with #103281 reverted, and patching bootstrap with the attached diff. Be sure to set At the time, it was easier to find with |
Closing this since the 3.10 changes make this obsolete anyway, regardless of caching. Probably the easiest thing to do to make best use of 3.10 code and keep the caching is to just cache the |
Proposed change
Reverts #103281 as it propagates an error for compressed files being fixed in aio-libs/aiohttp#8485. Rather than also fix it here, IMO just eliminating the copied code is the better solution as I think the logic for caching it is flawed.
#103281 guarantees that the content type is computed for each URI whenever the cache is clear on restart or there's a miss. However, many of those responses may be 304s (not modified) where the header isn't even needed. By contrast,
aiohttp
only computes it when it's actually going to send the file, in which case this little string operation would just be a drop in the bucket.Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: