Skip to content

Conversation

@thuongle2210
Copy link

@thuongle2210 thuongle2210 commented Nov 21, 2025

Summary

  • After reviewing the current caching implementation, I found that it only checks if the cache file exists locally but does not verify the ETag condition.

Version:

latest version

Resolve for issues:

issues-13

Changes

  • Fixes the bug by adding proper ETag validation before assuming the local cache is valid.

  • Ensures that cached files are only reused if the server confirms no changes via ETag.

  • Otherwise, downloads the updated file and updates the cache accordingly.

  • Add test cases covering both scenarios: server-side support for ETag and lack of ETag support.

  • Refactor other test cases in http.rs file

Impact

  • This change improves cache correctness and reduces unnecessary downloads, ensuring data freshness while leveraging caching efficiently.

@thuongle2210
Copy link
Author

thuongle2210 commented Nov 21, 2025

hi @habedi , I implemented the Etag to track the changed status of an object on the server. It accomplishes that the synchronization between local and remote files. Could you pls help me review this PR?

@codecov
Copy link

codecov bot commented Nov 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Member

@habedi habedi Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these libraries (added in the infera/Cargo.toml) needed as main dependencies? It seems to me they are needed for tests.

Copy link
Member

@habedi habedi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thuongle2210,

Hi,

Thanks for the PR. As you can see, I wrote a few comments on the PR. 😃

.create();
let url = format!("{}/ok_model.onnx", server.url());
#[actix_web::test]
async fn test_remote_model_download_and_cache_with_etag_enabled() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use mockito instead of actix-web, and make all the tests blocking (no async test)? TBH I think using actix-web is a bit of over-engineering at the moment.

}

#[actix_web::test]
async fn test_remote_model_download_and_cache_with_etag_disabled() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use mockito instead of actix-web, and make all the tests blocking (no async test)? TBH I think using actix-web is a bit of over-engineering at the moment.

hex = "0.4"
filetime = "0.2"

tokio = { version = "1", features = ["full"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need tokio, especially with all of its features enabled. I think, at the moment, Infera itself doesn't do anything that requires an async IO runtime.

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

Successfully merging this pull request may close these issues.

2 participants