Skip to content

Commit 2831c2f

Browse files
Copilothotlong
andcommitted
Add documentation for ETag hash truncation rationale
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent a1c0733 commit 2831c2f

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

packages/metadata/src/loaders/filesystem-loader.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ export class FilesystemLoader implements MetadataLoader {
304304

305305
/**
306306
* Generate ETag for content
307+
* Uses SHA-256 hash truncated to 32 characters for reasonable collision resistance
308+
* while keeping ETag headers compact (full 64-char hash is overkill for this use case)
307309
*/
308310
private generateETag(content: string): string {
309311
const hash = createHash('sha256').update(content).digest('hex').substring(0, 32);

packages/metadata/src/metadata-manager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ export class MetadataManager {
328328

329329
/**
330330
* Generate ETag for content
331+
* Uses SHA-256 hash truncated to 32 characters for reasonable collision resistance
332+
* while keeping ETag headers compact (full 64-char hash is overkill for this use case)
331333
*/
332334
private generateETag(content: string): string {
333335
const hash = createHash('sha256').update(content).digest('hex').substring(0, 32);

0 commit comments

Comments
 (0)