-
Notifications
You must be signed in to change notification settings - Fork 16
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
New response status code vs. Cache-Control: no-cache, patch #16
Comments
Why shouldn't braid patches be cached? They are cached given the version, no? We should just make ETag == Version. |
They should only be cached if the proxy understands the Braid protocol. Imagine a braid-aware client requests a HTML page, and the request goes through a CDN that doesn't support braid. Then the origin server will send a patch, or stream of patches, through the CDN. But if a non-braid client then requests that page via the CDN, the CDN could respond with a patch instead of the full resource. The non-braid client would then try to display a patch instead of HTML. I'm not entirely sure that this happens with CDNs, but it seems likely, and mirrors the way the Range Requests spec has been written. |
Also, as for ETags, they unfortunately do not == Version, because they depend on Content-Encoding, not just the response body. In other words, if the network channel gzips the response body, it'll have a different ETag, even though it's the same Version. |
Interesting fact about ETags, but not sure if it matters. I am realizing it does not really help with the fact that a new client still gets wrong contents, in your scenario. But I am not so sure if you are right about the scenario:
I do not thin this is possible, because content-type of the patch and non-patch is different. So if braid-aware client wants a patch at version X, it should issue GET with version header and content type set to some patch format. If it wants state at X, it should issue GET with version header and content type set to the format in which it wants the state (JSON or HTML). And braid-aware server will provide in the list of content types it accepts both the non-patch and patch content types. And all of those responses can be cached, because they are immutable. The only thing which is not immutable is asking for a resource or a patch without a version (in which case you get the latest state/patch). So I do not see a problem here? |
Actually, in the current spec—as in range requests—the Content-Type remains intact when you switch to a patch or a Range Response. Example (Range Request):
Example (current Braid spec):
I remember thinking about this fairly hard before making this design decision, but don't remember OTOH the specific use-cases that requires it. If I thought for a bit they might come back to mind... In the current spec, the thing that distinguishes a request for patches vs. full content is the presence of any of these headers:
I'm not sure if existing CDNs would distinguish requests containing these headers, or not, in caching. I bet this is spelled out somewhere in the HTTP specs... |
Oh, I missed that. That is a different design decision that what I was thinking/expecting, so maybe I skipped over that. Hm, I would love to understand why you would prefer this. I mean, in my view :
Those two are different to me.
There might be some caching option to tell which headers to use for caching? |
I'm not sure what you mean by this:
|
I am continuing the discussion from above. That we should use two different content types for state vs. patch. And that for patch we have a default content type we can use: the braid-patch one. So not sure why to have same content type and have this issue you are describing here? |
After more investigation here, you are right, when using range-requests you use same content-type as the full content is. And in that case partial content status code should be used to fix the caching problem you are describing. But when fetching a particular version, you would not be using really range requests. I mean, you can, especially with our new range units, but that would still be just fetching a subset of the state. So To that get that patch, I would suggest you issue a request where in
And there will be no caching issues with all of that. |
I think we can use Vary header and require Braid HTTP client to always list |
I'm not sure how the cache-control solution solves the problem here. Consider: https://tools.ietf.org/html/rfc7234#section-5.2.3
That means any cache that has no idea the |
@alficles, that's why the proposed Cache-Control header value is A cache that doesn't understand A cache that does understand However, we seem to have moved on to simply using a |
Ugh. This is why I shouldn't make comments on Friday afternoon. Sorry about that. I've got some other concerns about the 209 code, though. Adoption is going to be a real bear, because some proxies have a tendency to block what they don't understand. In any case, I think whatever Connection-oriented solution we find for #62 will greatly inform this decision here. |
Mmm, interesting point about proxies blocking what they don't understand! Again, I'm glad to have your expertise engaged to point out issues like this. This sounds like a question we might be able to test empirically. On the one hand, Running some tests on a variety of real networks should help us learn what to do about this. |
Unfortunately, I've found evidence that the status code 209 trick fails to prevent Chrome from caching. Specifically, I ran into this issue: https://stackoverflow.com/questions/27513994/chrome-stalls-when-making-multiple-requests-to-same-resource To reproduce this, I did this:
The PUT request gets delayed by 20 seconds, because Chrome thinks they are operating on the same cache, and locks its cache for 20 seconds. This issue goes away if you add "Cache-Control no-cache, no-transform". This suggests that some implementations might need the Cache-Control headers after all. We should test other browsers and proxies before making a final call. |
In order to prevent existing caches from trying to cache a patch, the current spec requires a patch to specify
Cache-Control: no-cache, patch
.However, I just discovered that the same problem was solved by HTTP Range Requests by inventing a new status code:
Should we switch to using a new status code for patch responses as well? This seems nicer than saying "Cache-Control: no-cache, patch", which implies, in rather circuitous fashion "Don't cache this. Oh, but you can cache this as a patch."
The text was updated successfully, but these errors were encountered: