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

Do not purge httpcache when transport or backend fails. #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mchheda-ld
Copy link

Description

In streamer we are often seeing issues where if 1 varnish node is unavailable, we end up evicting good data from the local cache and thus leads to full data transfer on retry.

Instead we want to introduce a new cache directory keep-on-error which instructs http cache then when backend or transport fails, do not purge current entry. It still returns underlying error to main flow.

stale-if-error can still override keep-on-error directive it returns cached entry.

resetTest()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", s.server.URL+"/evictonerror", nil)

Choose a reason for hiding this comment

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

It doesn't look like these tests ran in CI 🤔

one change - We added a handler for /keeponerror but we are using s.server.URL+"/evictonerror" here. Need to keep both same.

Other than these the PR is looking good

Copy link
Author

Choose a reason for hiding this comment

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

Yea we don't run it perhaps there was never a need coz it was simply cloned and never a commit was added. I ran tests locally and here is the result from latest commit.

Running tool: /Users/mahekchheda/.goenv/versions/1.22.7/bin/go test -timeout 10m -tags launchdarkly_easyjson -run ^(TestCacheableMethod|TestDontStorePartialRangeInCache|TestGetOnlyIfCachedHit|TestGetOnlyIfCachedMiss|TestGetNoStoreRequest|TestGetNoStoreResponse|TestGetWithEtag|TestGetWithLastModified|TestGetWithVary|TestGetWithDoubleVary|TestKeepOnError|TestGetWith2VaryHeaders|TestGetVaryUnused|TestUpdateFields|TestParseCacheControl|TestNoCacheRequestExpiration|TestNoCacheResponseExpiration|TestReqMustRevalidate|TestRespMustRevalidate|TestFreshExpiration|TestMaxAge|TestMaxAgeZero|TestBothMaxAge|TestMinFreshWithExpires|TestEmptyMaxStale|TestMaxStaleValue|TestGetEndToEndHeaders|TestStaleIfErrorRequest|TestStaleIfErrorRequestLifetime|TestStaleIfErrorResponse|TestStaleIfErrorResponseLifetime)$ github.com/launchdarkly/httpcache

ok  	github.com/launchdarkly/httpcache	0.390s

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