-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Option to reload or prevent caching of templates #163
Comments
I've handled this same issue out-of-band by using tools like watchexec --exts tera,hbs --restart "cargo run" Unless the template engines themselves support the feature (which they presently don't), I think adding this functionality to Rocket isn't a great idea. The complexity isn't worth the reward, in my opinion, especially when it's so easy to use an out-of-band tool. |
https://github.com/passcod/cargo-watch looks promising. It doesn't support running a server yet but it's on the top of their roadmap. |
Ok, that's fair enough. In fact, the Now the only remaining question is, what would be required to integrate LiveReload-like functionality (á la http://nitoyon.github.io/livereloadx) to Rocket? If Rocket told my web page to reload itself every time it started running again after |
I use the LiveReload application for exactly that, @trombonehero, no changes to Rocket needed. I simply monitor the directory where my application is, and |
@trombonehero Do you still feel like this is something Rocket should have built-in? |
I have found that the built-in LiveReload functionality of Hugo (https://gohugo.io) is quite useful because it's embedded directly in the HTML and doesn't require any extra browser support. For example, I can use livereloadx on my Mac, but on FreeBSD the Firefox plugin isn't supported, whereas the in-page functionality of Hugo works just fine. However, I can see how this sort of thing would have a pretty low priority in terms of wishlist. As for the original request, I think your response is entirely reasonable. It's even more compelling since I've started playing around with Maud, where the template is Rust code. So, I wouldn't at all object to this issue being closed if that seems like a good way to handle it to you. |
For now, I think this is something better handled outside of Rocket. Maybe one day we'll have a Closing this issue for now. |
Maybe it is worth opening this issue again, so we can talk about template reloading in more detail :-). |
I'd like to bump this. Would it be possible to re-parse a template every time a request is made (optional, developing environment). I think restarting the server every time one changes a little HTML shouldn't be necessary |
I am working on this issue now, informed by #523 (comment). I am to a point where the template context is reloaded on every request made in debug mode, including re-running the engine customization callback. The next step is to reload only when files were actually changed on disk; after that is done I will focus on cleaning up some rough edges and submit a PR. |
It would be super-helpful for development and debugging if Rocket could reload cached templates when I modify them, or else turn off caching altogether in development mode.
The text was updated successfully, but these errors were encountered: