Add support for HTTP ETags in llama-server#23701
Conversation
| if (const std::string & inm = req.get_header_value("If-None-Match"); | ||
| !inm.empty() && inm == a->etag) { | ||
| res.status = 304; | ||
| res.set_header("ETag", a->etag); |
There was a problem hiding this comment.
An alternative to a hash based etag could be a compile date + time based etag. The advantage here would be that the etag doesn't have to be computed with xxhash removing this dependency with the downside of having to redownloading the ui files after each rebuild.
ngxson
left a comment
There was a problem hiding this comment.
IMO the better implementation is to simply calculate the hash at compile time, not at runtime
|
The hash is compiled during the embedding phase during compile time. |
etag has to be set always Co-authored-by: Xuan-Son Nguyen <thichthat@gmail.com>
|
When trying to reproduce this locally I worked around multiple issues to make the E2E tests run successfully. My AI told me that Playwright 1.56.1 expects a headless shell while the chromium build installed through npx playwright install chromium was a full chrome binary. When installing the headless_shell the test succeeds with chromium. It also succeeds with Firefox on my system. |
|
the E2E test is not run via llama-server, so it's safe to ignore the error |
* allow caching of ui elements in llama-server * use fnv_hash * Update tools/server/server-http.cpp etag has to be set always Co-authored-by: Xuan-Son Nguyen <thichthat@gmail.com> --------- Co-authored-by: Xuan-Son Nguyen <thichthat@gmail.com>
* allow caching of ui elements in llama-server * use fnv_hash * Update tools/server/server-http.cpp etag has to be set always Co-authored-by: Xuan-Son Nguyen <thichthat@gmail.com> --------- Co-authored-by: Xuan-Son Nguyen <thichthat@gmail.com>
* allow caching of ui elements in llama-server * use fnv_hash * Update tools/server/server-http.cpp etag has to be set always Co-authored-by: Xuan-Son Nguyen <thichthat@gmail.com> --------- Co-authored-by: Xuan-Son Nguyen <thichthat@gmail.com>
Overview
The user interface of llama-server is served as embedded static files. For those files the httplib does not generate ETags used for browser caching. This change computes a hash for each statically embedded file to allow caching.
The javascript bundles has a size of around 5MB and it can take a considerable amount of time in low bandwidth environments to download this file each time one opens the llama-server webinterface. Using caching those files have to be downloaded only once.
Requirements
I have read and agree with the contributing guidelines
AI usage disclosure: yes: I have used an AI coding to understand llama-server and made it generate the required changes. I reworked the changes with AI to be minimal intrusive to avoid AI slop / bloat.