4 ms·
In terms of performance, the content hash based file name approach is easier to implement with SQLite storage. The content hash has to be generated just once du
by ajayvk 2y ago
In terms of performance, the content hash based file name approach is easier to implement with SQLite storage. The content hash has to be generated just once during file upload, not every time the web server is restarted (or using a build step which does actual file renames). It is possible to do it dynamically for file system files (see https://github.com/benbjohnson/hashfs https://github.com/benbjohnson/hashfs for a embedFS implementation), but the database makes it a bit easier.
- azornathogron 2y agoThis is pretty cool, but if you're rewriting resource names server side then you need some machinery to rewrite references to those resources. I see the example you linked shows the root HTML being generated server-side from a template so content hash names can be injected into the template. Looks reasonable. Not so great for dealing with things like `import` calls in javascript (for deferred loading of script modules), if those need to be rewritten as well. Your JS bundler (if you use one!) might be effectively rewriting imports anyway so it can be convenient to do the content-hash-named-files rewrites in the same place. But not everyone wants to use a bundler for that.
- ajayvk 2y agoClace can be used to build hypermedia driven UI's, using Go templates and HTMX. https://clace.io/docs/develop/templates/#static-function https://clace.io/docs/develop/templates/#static-function gives the content hashed file name, the templates have to use that function. See https://github.com/claceio/apps/blob/f5566cea6061ec85ea59495efc7b8700f06a4e70/misc/cowbull/index.go.html#L13 https://github.com/claceio/apps/blob/f5566cea6061ec85ea59495... for an example, that game is running live at https://cowbull.co/ https://cowbull.co/ Clace can also run containers, where the UI is served by the container. For example, Streamlit/Gradio based apps. In that case, Clace acts like an app server and reverse proxy to the container, no file name rewrites are done. Clace includes esbuild for being able to import npm packages as ES modules https://clace.io/docs/develop/javascript/ https://clace.io/docs/develop/javascript/. There is no support for any JS bundling.