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

Improve hacsfiles caching #1653

Closed
bdraco opened this issue Nov 15, 2020 · 4 comments · Fixed by #1655
Closed

Improve hacsfiles caching #1653

bdraco opened this issue Nov 15, 2020 · 4 comments · Fixed by #1655

Comments

@bdraco
Copy link
Contributor

bdraco commented Nov 15, 2020

One of my installs loads slow on mobile and I did some investigating and narrowed part of the issue down to the frontend having to re-download 9 js files in /hacsfiles/...

I'm trying to come up with a way to solve caching issue with the frontend files being loaded every time because of the custom_components.hacs.webresponses.category.async_serve_category_file explicitly disabling caching which I assume is to ensure updates can happen without clearing browser cache.

                response.headers["Cache-Control"] = "no-store, max-age=0"
                response.headers["Pragma"] = "no-store"

In my install I have 9 included JS files like:

/hacsfiles/lovelace-card-tools/card-tools.js

I'm thinking one way to allow caching would be do so something like

/hacsfiles/id-<HASH>/lovelace-card-tools/card-tools.js

Then any url that matches /hacsfiles/id- could have id-<HASH> stripped.

When the card-tools.js file changes, recalculate the hash of the file contents and change the url in the frontend if needed.

@hacs-bot
Copy link

hacs-bot bot commented Nov 15, 2020

Make sure you have read the issue guidelines and that you filled out the entire template.

@ludeeus
Copy link
Member

ludeeus commented Nov 15, 2020

Files are requested by browser clients.
There are no way of signaling that out to all (both connected, and disconnected clients).

@bdraco
Copy link
Contributor Author

bdraco commented Nov 16, 2020

I've been digging around for a way to trigger a "frontend update" when lovelace resources are updated but I haven't found a good way to do it.

My workaround was to switch out /hacsfiles for /local/community and manually clear cache when something changes.

@ludeeus
Copy link
Member

ludeeus commented Nov 16, 2020

I have spent a lot of time on figuring out something in the past, but nothing was stable enough for me to implement without it causing issues for disconnected clients / mobile apps

@ludeeus ludeeus added this to the 1.9.0 milestone Nov 22, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants