-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
stale content not being updated #201
Comments
By "returns the stale content" do you mean that Ledge continues to serve the stale content, even though the background task correctly fetched fresh content? Or that the newly refreshed content somehow appears to be the old stale version? Is the origin another Ledge instance by any chance? Or perhaps another system capable of serving stale-on-error? Ledge won't serve stale content if it has fresh content. So there should be no need to override the |
The background task returns the stale content from ledge that it already had, it never fetches from the origin. |
If I apply this patch instead (so I can log the state and event history, but keep the extra
so I get the original request, and then the revalidation attempt also gets a 'HIT' back from ledge, which is my problem. |
I see. You shouldn't need to be doing this with custom headers of course. The semantics are there already; the background request should include Hmm, which is an interesting point. That is, I think you could see the behaviour you are describing if the content has been refreshed by some other request in the mean time. The background task sets At the risk of hand-waving, there are a lot of tests for this behaviour. It's been so many years since I've thought about it though, that it's hard for me to be certain about much. If it still looks like a bug to you, I'd start by trying to recreate the conditions in the test harness (see the existing integration tests for examples: https://github.com/ledgetech/ledge/blob/master/t/02-integration/stale-while-revalidate.t). I'd take the request and response headers from your real world scenario and plug them into a similar test so that you can inspect the results in isolation. Take note of the In summary though; I agree you should not be seeing the behaviour that you appear to be. It was designed to do what you expect, using HTTP semantics to ensure background tasks never get stale content. They will get fresh content if some other thread has already refreshed the content, which is correct (i.e. harmless) and helps protect the origin. |
I have an upstream that has a short lived max-age and slightly longer stale headers, that once I get past that time, content isn't refreshed.
The cache headers from the upstream are:
I can see ledge triggering a background refresh, but when it tries to fetch the new content, it returns the stale content again (no matter how long I wait).
A dumb fix is attached.
stale.patch
The text was updated successfully, but these errors were encountered: