Add ETag support for static files - #834
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add mechanism for serving files with ETag headers
Add ETag support for static files
Jul 15, 2026
ademar
approved these changes
Jul 15, 2026
ademar
marked this pull request as ready for review
July 15, 2026 14:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suave.Fileshad no ETag support, so clients could only revalidate cached static files viaIf-Modified-Since(second-precision only).Changes
Files.filenow emitsETag: W/"{length:x}-{ticks:x}"derived fromFileInfo.Length+LastWriteTimeUtc.Ticks. No hashing, noFileSystemWatcher, no extra I/O beyond thestatalready needed forLast-Modified, so the opt-in concern raised in the issue doesn't apply.If-None-Matchhandling —ServeResource.resourceshort-circuits to304 Not Modifiedbefore theIf-Modified-Sincebranch. Supports*and comma-separated tag lists; comparison is opaque-string equality after trim (RFC 7232 §3.2 weak comparison — correct when the client echoes back what we sent). TheETagheader is re-emitted on the 304 (which resets headers).ServeResource.resourcesignature — newgetEtag : string -> string optionparameter. Embedded-asset serving passesfun _ -> None, preserving existing behavior.Files.fileEtag : string -> stringexposed for callers who want the same value (e.g. custom pipelines).HttpFile.fs: emitted on 200, stable across calls, match → 304, 304 carries ETag, non-match → 200,*→ 304.docs/files.md.Example