Skip to content

Same ETag is used for two different versions of the resource #2101

@koca2000

Description

@koca2000

Environment

  • Server version: 7.1.7
  • Node.js version: 22.21.1
  • npm version: 10.9.4

Description

The ETag sent by the CSS uses a UNIX timestamp to distinguish between different versions of a single resource. The timestamp is in seconds, which causes issues when two modification requests are done within one second. In this case, the client that made the request first receives a 302 Not Modified response for subsequent GET requests, even though the resource contains different data.

I took a look to the code and the behavior is caused by the updateModifiedDate function which removes milliseconds from the metadata.

export function updateModifiedDate(metadata: RepresentationMetadata, date = new Date()): void {
// Milliseconds get lost in some serializations, potentially causing mismatches
const lastModified = new Date(date);
lastModified.setMilliseconds(0);
metadata.set(DC.terms.modified, toLiteral(lastModified.toISOString(), XSD.terms.dateTime));
}

I think that the comment about issues with milliseconds refers to the fact that the HTTP headers If-Modified-Since and If-Unmodified-Since do not include milliseconds. The values of these two headers are used to check BasicConditions.

const modified = metadata.get(DC.terms.modified);
if (modified) {
const modifiedDate = new Date(modified.value);
if (this.modifiedSince && modifiedDate < this.modifiedSince) {
return false;
}
if (this.unmodifiedSince && modifiedDate > this.unmodifiedSince) {
return false;
}
}

I have not found any other place where the presence of milliseconds in the dcterms:modified value could cause problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions