magnars / stasis

Some Clojure functions for creating static websites.
348 stars 27 forks source link

Serving pages lazily #31

Open craftybones opened 3 years ago

craftybones commented 3 years ago

I am trying to serve markdown lazily in development. By this, I mean that if I update a markdown file, I wish for the changes to reflect when I refresh the browser. I can do this by serving functions instead of the raw content as strings. I am determining the URL by a slug on the markdown metadata. I am also using slurp-resources.

While I get my desired behaviour of a browser refresh accurately reflecting the latest changes, it is rendering every page not just the one I refreshed. I will potentially have a lot of pages with a lot of svg in it, so this is not desirable.

What would you recommend to achieve what I seek? One way is to simply re-read the file when the request comes. Is there a better way?

magnars commented 3 years ago

From the README:

image

I take it this is what you are doing, and it still renders every page? Stasis doesn't do that on its own. It will only call the function that matches the request. Could you share more of what you are doing?