Skip to content

feat: Implement basic HTTP caching with ETag and Last-Modified#5

Merged
nuclearcat merged 2 commits intokernelci:mainfrom
nuclearcat:add-caching-headers
Aug 8, 2025
Merged

feat: Implement basic HTTP caching with ETag and Last-Modified#5
nuclearcat merged 2 commits intokernelci:mainfrom
nuclearcat:add-caching-headers

Conversation

@nuclearcat
Copy link
Copy Markdown
Member

This commit introduces handling for If-None-Match and If-Modified-Since headers.

  • Adds ETag and Last-Modified headers to the response.
  • Checks for If-None-Match and If-Modified-Since in the request headers.
  • Returns a 304 Not Modified response if the cache is still valid.

@igorp-collabora
Copy link
Copy Markdown

RFC9110 explains the purpose of this headers and their handling: https://www.rfc-editor.org/rfc/rfc9110.html#name-if-none-match

Comment thread src/main.rs Outdated
}
}
// Does request have If-Modified-Since header?
if let Some(if_modified_since) = rxheaders.get("If-Modified-Since") {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to RFC9110 the If-Modified-Since should be ignored if If-None-Match is present.

A recipient MUST ignore If-Modified-Since if the request contains an If-None-Match header field; the condition in If-None-Match is considered to be a more accurate replacement for the condition in If-Modified-Since, and the two are only combined for the sake of interoperating with older intermediaries that might not implement If-None-Match

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@nuclearcat nuclearcat force-pushed the add-caching-headers branch from acf5a7c to 64f03c9 Compare August 7, 2025 13:01
This commit introduces handling for `If-None-Match` and `If-Modified-Since` headers.

- Adds `ETag` and `Last-Modified` headers to the response.
- Checks for `If-None-Match` and `If-Modified-Since` in the request headers.
- Returns a `304 Not Modified` response if the cache is still valid.

Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
@nuclearcat nuclearcat force-pushed the add-caching-headers branch from 64f03c9 to 18e62d8 Compare August 7, 2025 14:24
The Docker image name in the build workflow was pointing to a personal repository instead of the official KernelCI repository. This commit corrects the image name to `ghcr.io/kernelci/kernelci-storage`.
@nuclearcat
Copy link
Copy Markdown
Member Author

I did few adjustments also for RFC9110 compliance.

@nuclearcat nuclearcat merged commit 3edd5e2 into kernelci:main Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants