Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(proxy): Include a X-Cache Header #313

Merged
merged 1 commit into from
Mar 10, 2023

Conversation

Blokje5
Copy link
Collaborator

@Blokje5 Blokje5 commented Mar 3, 2023

Description

X-Cache will be set to HIT if a response came from the Cache, otherwise it will be set to MISS. As explained in the #288, this can help to determine the accuracy of the ClickHouse stats in the response (and there might be other use cases).

Fixes #288

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Checklist

  • Linter passes correctly
  • Add tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary

Does this introduce a breaking change?

  • Yes
  • No

Further comments

@Blokje5
Copy link
Collaborator Author

Blokje5 commented Mar 3, 2023

golangci-lint seems to have been failing for a while, also on the master branch

@sigua-cs
Copy link
Collaborator

sigua-cs commented Mar 5, 2023

golangci-lint seems to have been failing for a while, also on the master branch

Let's try to upgrade golangci-lint and action. I'll prepare a PR

@mga-chka
Copy link
Collaborator

mga-chka commented Mar 6, 2023

becareful, upgrading the golangci-lint is a risk to have new issues to fix

proxy.go Outdated
@@ -457,7 +457,7 @@ func (rp *reverseProxy) serveFromCache(s *scope, srw *statResponseWriter, req *h

rp.completeTransaction(s, statusCode, userCache, key, q, "")

err = RespondWithData(srw, reader, contentMetadata, 0*time.Second, tmpFileRespWriter.StatusCode(), labels)
err = RespondWithData(srw, reader, contentMetadata, 0*time.Second, false, tmpFileRespWriter.StatusCode(), labels)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if in this case the value of the X-Cache header should be something else like N/A because even if it's a cache miss, it's something chproxy is not supposed to cache.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense. I will push an update to this PR soon and introduce N/A.

@Blokje5 Blokje5 force-pushed the feat/x-cache-header branch 2 times, most recently from 0e8bbf1 to a51949d Compare March 10, 2023 14:06
…had a cache miss or hit.

X-Cache will be set to HIT if a response came from the Cache, otherwise it will be set to MISS.

Fixes ContentSquare#288

Signed-off-by: Lennard Eijsackers <lennardeijsackers92@gmail.com>
@Blokje5 Blokje5 merged commit 65324e8 into ContentSquare:master Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Detecting cache hit
3 participants