Use source mtime for Last-Modified and unify modified-since semantics#1326
Use source mtime for Last-Modified and unify modified-since semantics#1326lovasoa wants to merge 1 commit into
Conversation
|
@codex I clearly see the runtime overhead, but not the concrete benefits. We are making one entire new db query per file, for no functional change ? Either justify it or drop it |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac22aeeb36
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| path: &Path, | ||
| ) -> anyhow::Result<DateTime<Utc>> { | ||
| self.last_modified | ||
| .query_as::<(DateTime<Utc>,)>() |
There was a problem hiding this comment.
Handle nullable database modification timestamps
The documented and generated sqlpage_files schemas allow last_modified to be NULL for several databases, so a row inserted with an explicit NULL was previously still readable and servable. Decoding it as DateTime<Utc> rejects NULL, and serve_file now calls this method before every static-file read, causing requests for such DB-backed assets to return a 500 instead of their contents. Decode an optional timestamp and provide an appropriate fallback or omit the header for NULL values.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
You have reached your Codex usage limits. You can see your limits in the Codex usage dashboard.
Summary
Testing
|
|
@codex monitor ci error[E0283]: type annotations needed error[E0283]: type annotations needed For more information about this error, try |
|
You have reached your Codex usage limits. You can see your limits in the Codex usage dashboard. |
Motivation
Last-Modified: now, which changes on every request and prevents meaningful cache revalidation.>vs DB>=), causing inconsistent conditional-request behavior.Description
FileSystem::last_modifiedwhich returns the real modification time from the local filesystem or thelast_modifiedcolumn in the DB-backedsqlpage_filestable.last_modifiedvalue (make_last_modified_queryandlast_modified_in_db) and changed the DBwas_modifiedcheck to strict>to match local semantics.serve_fileto computelast_modified, use it forIf-Modified-Sincevalidation, and insert the sameLast-Modifiedvalue on both200 OKand304 Not Modifiedresponses.Last-Modifiedand revalidate correctly, and an assertion in the DB test that a file is not considered modified since its exact timestamp.Testing
cargo fmt --allandcargo fmt --all -- --check, and verifiedgit diff --check; these passed.cargo clippy --all-targets --all-features -- -D warnings, but it was blocked by the environmentlibsqlite3-sys 0.38.1build error using the unstablecfg_selectfeature with the installedrustc.cargo testand running the newstatic_file_uses_source_last_modified_for_revalidationtest, but test execution was blocked by the samelibsqlite3-sysbuild error.libsqlite3-sys(or the dependency is adjusted).Codex Task