From a418d7d2736906c24df64f7ffcf482966b1083ba Mon Sep 17 00:00:00 2001 From: Ashwani Jha Date: Tue, 5 May 2026 01:10:13 +0530 Subject: [PATCH] docs: fix misleading etagFn example --- src/http/handlers/static/static-file-handler.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/http/handlers/static/static-file-handler.ts b/src/http/handlers/static/static-file-handler.ts index 424c207..8ef7f60 100644 --- a/src/http/handlers/static/static-file-handler.ts +++ b/src/http/handlers/static/static-file-handler.ts @@ -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;