-
Notifications
You must be signed in to change notification settings - Fork 7
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 reload experience when using with site generator such as cargo doc #83
Conversation
f6e77f8
to
eb4c662
Compare
Thanks for your contribution. However I'm quite busy lately and can't spare extra time for reviewing currently. I will review it after I finish my work in about one or two week(s) :) |
I also just tested it on my laptop with 11th gen i5. It's pretty smooth for lower-end device as well :) |
Thanks for the review, I will update it soonish |
LGTM. Now just needs some adjustments to pass the checks. |
168f47d
to
96a99a8
Compare
Should be fixed now |
Thanks for making this tool! I was looking into making something similar but it would take me way longer if I were to start from scratch... I found some issues when using this as a live-reload service for
cargo doc
. Please find the details and fix belowProblem Description
cargo doc
, the server can send update before the build is done, causing massive flickering and in the worst case, stuck on a 404 page.location.reload()
can still cause slight flickering because assets are not cachedThe issue(s) can be observed by running
live-server target/doc
andcargo watch -x doc
side-by-side (requires cargo-watch)Issue screenshot
Fix Description
?reload
and ensure it can load before triggering the reload. The server injects ameta
tag if the page is a success response for reload (to distinguish it from 404 page)location.reload()
, the client:Because the assets are cached, the reload experience is smoother
hard_reload()/--hard
to turn the optimization off and call location.reload() instead. This still ensures the page can be loaded so (1) is not an issue.Testing
Screenshots:
Hard Reload (notice the slight flicker)
Hot Reload
Other
Not related to everything above, I also found an issue where links in the output of
cargo doc
were broken because../
behaves differently when the path is<origin>/live_server
vs.<origin>/live_server/
or<origin>/live_server/index.html
.so I added a check to redirect directories that don't end with slash. This might break scenarios that rely on this bug