-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Gateway: Add Cache-Control/max-age and ETag to IPNS requests #1921
Conversation
f008ecb
to
e905204
Compare
6e96a45
to
85b8962
Compare
338a8ac
to
763370f
Compare
// and only if it's /ipfs! | ||
// TODO: break this out when we split /ipfs /ipns routes. | ||
w.Header().Set("ETag", etag) | ||
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", int(res.TTL.Seconds()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, errors still happen below. this is trickty! -- maybe the error functions should clear this header to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ensure it's /ipfs/
route. code evolves!
763370f
to
42060d8
Compare
|
Ok, this LGTM to me. @ion1 last thing is we should test some of this using sharness tests, so that the api tests are carried to other impls eventually. |
42060d8
to
deb7184
Compare
The sharness tests involving IPNS were All the new IPNS tests in the PR are Should I leave them as they are (which leaves the test suite failing until the |
deb7184
to
2765be6
Compare
I created #1941, changed them to |
c0b09e0
to
b020415
Compare
@ion1 Looking much better! some comments above. |
6ee526f
to
f44ebdb
Compare
@jbenet, thanks for your input. Done:
|
The Travis failure does not seem to have anything to do with my changes. |
// Remember to unset the Cache-Control/ETag headers before error | ||
// responses! The webError functions unset them automatically. | ||
// TODO: Consider letting clients cache 404s. Are there cases where | ||
// that would hurt? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes let's not cache 404s anytime soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s unclear to me where it would hurt, though. Given a successfully resolved /ipfs/QmFoo
, the knowledge that “/ipfs/QmFoo/fileA
exists” should be as cacheable as “/ipfs/QmFoo/fileB
does not exist” for example. QmFoo
is immutable after all.
The same applies to /ipns/QmBar
. The record’s TTL dictates that the knowledge that “/ipns/QmBar/fileA
exists” can be cached for just as long as that “/ipns/QmBar/fileB
does not exist”.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think @ion1 has a point here, but its going to be difficult to do it right. A 404 should only be cached if its for a link under a valid resolved hash. A 'could not find this hash on the network' 404 should never be cached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code should already return a TTL of 0 for all network failures.
@ion1 thanks -- more CR. and rebase to keep abreast of recent merges. |
Closes ipfs#1934. License: MIT Signed-off-by: Johan Kiviniemi <[email protected]>
License: MIT Signed-off-by: Johan Kiviniemi <[email protected]>
License: MIT Signed-off-by: Johan Kiviniemi <[email protected]>
License: MIT Signed-off-by: Johan Kiviniemi <[email protected]>
License: MIT Signed-off-by: Johan Kiviniemi <[email protected]>
Closes ipfs/go-ipfs#1818. License: MIT Signed-off-by: Johan Kiviniemi <[email protected]>
f44ebdb
to
e312125
Compare
@jbenet, thanks for your input. Done:
I’m looking forward to your response to my comment about |
@@ -10,12 +10,14 @@ test_description="Test ipfs repo operations" | |||
|
|||
test_init_ipfs | |||
|
|||
for TTL_PARAMS in "" "--ttl=0s" "--ttl=1h"; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow the rest of the file is in a for loop without indentation. didnt even catch this the first time. please dont do that.
do this instead:
somefunc() {
TTL=$1
all the tests here
}
for TTL in "" "--ttl=0s" "--ttl=1h"; do
somefunc $TTL
done
@ion1 since this PR touches a lot of files, I'd prefer if we put this on 0.4.0. Give rebasing it a shot, let me know how it goes. |
also, the infinite duration stuff (which i'm still not convinced is better than just using -1 as a special value) should go in thirdparty, i'm working on shrinking the util package. |
@ion1 update here? |
@whyrusleeping: I have been waiting for a fix for #1941 which prevents the tests in this PR from working. I will rebase this and address the other remaining comments at that point. |
Has been idle for about a year. Closing for now. Please do feel free to reopen this as necessary. Closing old PRs just helps us more easily see what needs immediate attention |
Based on #1887 “cache ipns entries to speed things up a little”.
Addresses https://github.com/ipfs/go-ipfs/issues/1818.
This is my first time learning Go, I hope I’m doing things somewhat correctly.