Skip to content

Commit 8537cd2

Browse files
CopilotL3P3
andcommitted
Remove redundant ETag implementation, keep only Last-Modified
Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
1 parent d56c9d6 commit 8537cd2

1 file changed

Lines changed: 2 additions & 18 deletions

File tree

rtjscomp.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,31 +1526,16 @@ const request_handle = async (request, response, https) => {
15261526
}
15271527
}
15281528

1529-
// Generate ETag from modification time and file size
1529+
// Generate Last-Modified header from file modification time
15301530
const mtime_ms = file_stat.mtimeMs;
1531-
const etag = `"${mtime_ms.toString(36)}-${file_stat.size.toString(36)}"`;
15321531
const last_modified = new Date(mtime_ms).toUTCString();
15331532

1534-
// Check If-None-Match (ETag validation)
1535-
if ('if-none-match' in request_headers) {
1536-
const if_none_match = request_headers['if-none-match'];
1537-
if (if_none_match === etag || if_none_match === '*') {
1538-
response.setHeader('ETag', etag);
1539-
response.setHeader('Cache-Control', 'public, max-age=31536000');
1540-
throw 304;
1541-
}
1542-
}
1543-
15441533
// Check If-Modified-Since (time-based validation)
1545-
if (
1546-
'if-modified-since' in request_headers &&
1547-
!('if-none-match' in request_headers)
1548-
) {
1534+
if ('if-modified-since' in request_headers) {
15491535
const if_modified_since = new Date(request_headers['if-modified-since']);
15501536
// Round mtime down to seconds for comparison (HTTP dates don't have millisecond precision)
15511537
const mtime_seconds = Math.floor(mtime_ms / 1000) * 1000;
15521538
if (!isNaN(if_modified_since) && mtime_seconds <= if_modified_since.getTime()) {
1553-
response.setHeader('ETag', etag);
15541539
response.setHeader('Last-Modified', last_modified);
15551540
response.setHeader('Cache-Control', 'public, max-age=31536000');
15561541
throw 304;
@@ -1559,7 +1544,6 @@ const request_handle = async (request, response, https) => {
15591544

15601545
if (spam_enabled) spam('static_send', [path, file_compression]);
15611546
response.setHeader('Cache-Control', 'public, max-age=31536000');
1562-
response.setHeader('ETag', etag);
15631547
response.setHeader('Last-Modified', last_modified);
15641548
if (compression_enabled_type) {
15651549
response.setHeader('Vary', 'Accept-Encoding');

0 commit comments

Comments
 (0)