Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/http/handlers/static/static-file-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,16 @@ export interface StaticFileOptions {
* which creates ETags based on file statistics (size and modification time).
*
* You can provide a custom function to override the default behavior.
* For example, to generate content-based ETags using file hashing:
* For example:
*
* ```ts
* etagFn: (stat) => {
* const hash = crypto.createHash('md5').update(fileContent).digest('hex');
* return `"${hash}"`;
* return `"${stat.size.toString(16)}-${stat.mtimeMs.toString(16)}"`;
* }
* ```
*
* Note: Content-based ETags require reading the entire file, which impacts performance.
* The default stat-based approach is much faster and suitable for most use cases.
* Note: The 'etagFn' only recieves file stats (`fs.Stats`) and does not have access
* to file content.
*/
etagFn?: (stat: fs.Stats) => string;

Expand Down
Loading