Skip to content
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

service-worker caching policy too aggressive #14836

Open
3 tasks done
kantlivelong opened this issue Dec 20, 2022 · 16 comments
Open
3 tasks done

service-worker caching policy too aggressive #14836

kantlivelong opened this issue Dec 20, 2022 · 16 comments

Comments

@kantlivelong
Copy link

kantlivelong commented Dec 20, 2022

Checklist

  • I have updated to the latest available Home Assistant version.
  • I have cleared the cache of my browser.
  • I have tried a different browser to see if it is related to my browser.

Describe the issue you are experiencing

When running Home Assistant behind a reverse proxy along with other web apps service-worker.js will cache content from other apps which causes them to break. Currently service-worker is configured to cache anything that comes back with a 200 (or 0) status code.

An example of this is:

  1. Two apps/services behind a reverse proxy:
    -- (A) Home Assistant being served at https://domain.tld/
    -- (B) Z-Wave JS UI being served at https://domain.tls/_/zwavejs2mqtt
  2. Ensure cache is cleared and service worker not registered.
  3. Browse to B, this should work
  4. Browse to A, also works.
  5. Now go back to B. You'll notice that data served by web socket no longer works. This is because service-worker is caching session details that are provided via a GET request.

Describe the behavior you expected

service-worker should only cache things that actually relate to HA.

Would it be worthwhile to cache content based on a header?
https://developer.chrome.com/docs/workbox/modules/workbox-cacheable-response/#caching-based-on-headers
https://github.com/home-assistant/frontend/blob/dev/src/entrypoints/service_worker.ts#L64

Steps to reproduce the issue

High level reproduction steps are outlined in the problem. Can provide specific configs/setup information if needed.

What version of Home Assistant Core has the issue?

core-2022.12.7

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

FireFox 108

Which operating system are you using to run this browser?

Linux Mint 21

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

@mitchcapper
Copy link

Fantastic find, confirmed to happen in chrome too and break plenty of other items running on the same hostname.

@mitchcapper
Copy link

For a temporary work around you can add an exception for a prefix to the cacher. This is very fragile as it depends on their obfuscated code but wfm for now:
sed -i 's#re(new RegExp("/(api|auth)/.*"),new le)#re(new RegExp("/(api|auth)/.*"),new le),re(new RegExp("/SOME_PREFIX_HERE.*"),new le)#' /usr/local/lib/python3.10/site-packages/hass_frontend/service_worker.js

then as long as /SOME_PREFIX_HERE is used to start a proxy path it won't cache it. If the code changes just search that file for api|auth and copy that regex code and add another for what you want.

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Apr 16, 2023
@kantlivelong
Copy link
Author

This is still an issue.

@github-actions github-actions bot removed the stale label Apr 17, 2023
@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jul 22, 2023
@kantlivelong
Copy link
Author

This is still an issue.

@github-actions github-actions bot removed the stale label Jul 22, 2023
@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Oct 20, 2023
@kantlivelong
Copy link
Author

This is still an issue.

@github-actions github-actions bot removed the stale label Oct 20, 2023
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jan 18, 2024
@kantlivelong
Copy link
Author

This is still an issue.

@github-actions github-actions bot removed the stale label Jan 18, 2024
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Apr 17, 2024
@kantlivelong
Copy link
Author

This is still an issue.

@github-actions github-actions bot removed the stale label Apr 17, 2024
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jul 16, 2024
@kantlivelong
Copy link
Author

This is still an issue.

@github-actions github-actions bot removed the stale label Jul 16, 2024
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Oct 14, 2024
@mitchcapper
Copy link

still an issue

@github-actions github-actions bot removed the stale label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants