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

Return Last-Modified header in response for compatibility with Live.js #7

Open
rads opened this issue May 8, 2023 · 2 comments
Open

Comments

@rads
Copy link

rads commented May 8, 2023

I can contribute a PR here if desired. Just want to document the bug first.

Description:
babashka.http-server is used with Live.js to hot-reload changes to HTML, CSS, and JS. It uses HEAD requests to check the following headers: Etag, Last-Modified, Content-Length, and Content-Type.

Problem:
babashka.http-server doesn't return Last-Modified headers in the HTTP response. This means Live.js will fall back to using Content-Length to determine if there are new changes. It's possible for this to cause missed reloads since some changes (such as changing an integer in CSS) will result in the same Content-Length even though the content has changed.

When I use python3 -m http.server to serve the same files, I don't miss any changes even if the output file length is the same.

Solution:
Use ring.middleware.not-modified or something similar to add the Last-Modified to the HTTP responses.

@rads
Copy link
Author

rads commented May 8, 2023

Actually I realize now that ring.middleware.not-modified doesn't actually add the header itself. That's handled elsewhere such as in ring.util.response/file-response.

@borkdude
Copy link
Collaborator

borkdude commented May 8, 2023

I'd be fine with adding that. Perhaps we could even use the middleware directly in this project? PR welcome, if you get to it earlier than I do.

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