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

Http cache #5137

Merged
merged 44 commits into from
Mar 23, 2017
Merged

Http cache #5137

merged 44 commits into from
Mar 23, 2017

Conversation

mnot
Copy link
Member

@mnot mnot commented Mar 14, 2017

Add tests for HTTP caching in Fetch. See also whatwg/fetch#496.

Caveats in README.md.

@wpt-pr-bot
Copy link
Collaborator

Notifying @annevk, @jdm, and @youennf. (Learn how reviewing works.)

@ghost
Copy link

ghost commented Mar 14, 2017

These tests are now available on w3c-test.org

@ghost
Copy link

ghost commented Mar 14, 2017

View the complete job log.

Firefox (nightly channel)

Testing web-platform-tests at revision c3b1efa
Using browser at version BuildID 20170314110401; SourceStamp 6d38ad302429c98115c354d643e81987ecec5d3c
Starting 10 test iterations
All results were stable

All results

8 tests ran
/fetch/http-cache/304-update.html
Subtest Results Messages
OK
HTTP cache updates returned headers from a Last-Modified 304. PASS
HTTP cache updates stored headers from a Last-Modified 304. PASS
HTTP cache updates returned headers from a ETag 304. PASS
HTTP cache updates stored headers from a ETag 304. PASS
/fetch/http-cache/cc-request.html
Subtest Results Messages
OK
HTTP cache doesn't use aged but fresh response when request contains Cache-Control: max-age=0. PASS
HTTP cache doesn't use aged but fresh response when request contains Cache-Control: max-age=1. PASS
HTTP cache doesn't use fresh response with Age header when request contains Cache-Control: max-age that is greater than remaining freshness. PASS
HTTP cache does use aged stale response when request contains Cache-Control: max-stale that permits its use. PASS
HTTP cache does reuse stale response with Age header when request contains Cache-Control: max-stale that permits its use. PASS
HTTP cache doesn't reuse fresh response when request contains Cache-Control: min-fresh that wants it fresher. PASS
HTTP cache doesn't reuse fresh response with Age header when request contains Cache-Control: min-fresh that wants it fresher. PASS
HTTP cache doesn't reuse fresh response when request contains Cache-Control: no-cache. PASS
HTTP cache validates fresh response with Last-Modified when request contains Cache-Control: no-cache. PASS
HTTP cache validates fresh response with ETag when request contains Cache-Control: no-cache. PASS
HTTP cache doesn't reuse fresh response when request contains Cache-Control: no-store. PASS
HTTP cache generates 504 status code when nothing is in cache and request contains Cache-Control: only-if-cached. FAIL assert_equals: Response status expected 504 but got 200
/fetch/http-cache/freshness.html
Subtest Results Messages
OK
HTTP cache reuses a response with a future Expires. PASS
HTTP cache does not reuse a response with a past Expires. PASS
HTTP cache does not reuse a response with a present Expires. PASS
HTTP cache does not reuse a response with an invalid Expires. PASS
HTTP cache reuses a response with positive Cache-Control: max-age. PASS
HTTP cache does not reuse a response with Cache-Control: max-age=0. PASS
HTTP cache reuses a response with positive Cache-Control: max-age and a past Expires. PASS
HTTP cache reuses a response with positive Cache-Control: max-age and an invalid Expires. PASS
HTTP cache does not reuse a response with Cache-Control: max-age=0 and a future Expires. PASS
HTTP cache does not prefer Cache-Control: s-maxage over Cache-Control: max-age. PASS
HTTP cache does not reuse a response when the Age header is greater than its freshness lifetime. FAIL assert_equals: Response used expected 2 but got 1
HTTP cache does not store a response with Cache-Control: no-store. PASS
HTTP cache stores a response with Cache-Control: no-cache, but revalidates upon use. PASS
/fetch/http-cache/heuristic.html
Subtest Results Messages
OK
HTTP cache reuses an unknown response with Last-Modified based upon heuristic freshness when Cache-Control: public is present. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache does not reuse an unknown response with Last-Modified based upon heuristic freshness when Cache-Control: public is not present. PASS
HTTP cache reuses a 200 OK response with Last-Modified based upon heuristic freshness. PASS
HTTP cache reuses a 203 Non-Authoritative Information response with Last-Modified based upon heuristic freshness. PASS
HTTP cache reuses a 204 No Content response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache reuses a 404 Not Found response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache reuses a 405 Method Not Allowed response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache reuses a 410 Gone response with Last-Modified based upon heuristic freshness. PASS
HTTP cache reuses a 414 URI Too Long response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache reuses a 501 Not Implemented response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache does not use a 201 Created response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 202 Accepted response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 403 Forbidden response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 502 Bad Gateway response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 503 Service Unavailable response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 504 Gateway Timeout response with Last-Modified based upon heuristic freshness. PASS
/fetch/http-cache/invalidate.html
Subtest Results Messages
OK
HTTP cache invalidates after a successful response from a POST PASS
HTTP cache does not invalidate after a failed response from an unsafe request FAIL assert_less_than: Response used expected a number less than 3 but got 3
HTTP cache invalidates after a successful response from a PUT PASS
HTTP cache invalidates after a successful response from a DELETE PASS
HTTP cache invalidates after a successful response from an unknown method PASS
HTTP cache invalidates Location URL after a successful response from a POST PASS
HTTP cache does not invalidate Location URL after a failed response from an unsafe request FAIL assert_less_than: Response used expected a number less than 3 but got 3
HTTP cache invalidates Location URL after a successful response from a PUT PASS
HTTP cache invalidates Location URL after a successful response from a DELETE PASS
HTTP cache invalidates Location URL after a successful response from an unknown method PASS
HTTP cache invalidates Content-Location URL after a successful response from a POST PASS
HTTP cache does not invalidate Content-Location URL after a failed response from an unsafe request FAIL assert_less_than: Response used expected a number less than 3 but got 3
HTTP cache invalidates Content-Location URL after a successful response from a PUT PASS
HTTP cache invalidates Content-Location URL after a successful response from a DELETE PASS
HTTP cache invalidates Content-Location URL after a successful response from an unknown method PASS
/fetch/http-cache/partial.html
Subtest Results Messages
OK
HTTP cache stores partial content and reuses it. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache stores complete response and serves smaller ranges from it. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache stores partial response and serves smaller ranges from it. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache stores partial content and completes it. FAIL assert_equals: expected (string) "bytes=5-" but got (undefined) undefined
/fetch/http-cache/status.html
Subtest Results Messages
OK
HTTP cache goes to the network if it has a stale 200 response. PASS
HTTP cache avoids going to the network if it has a fresh 200 response. PASS
HTTP cache goes to the network if it has a stale 203 response. PASS
HTTP cache avoids going to the network if it has a fresh 203 response. PASS
HTTP cache goes to the network if it has a stale 204 response. PASS
HTTP cache avoids going to the network if it has a fresh 204 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache goes to the network if it has a stale 299 response. PASS
HTTP cache avoids going to the network if it has a fresh 299 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache goes to the network if it has a stale 400 response. PASS
HTTP cache avoids going to the network if it has a fresh 400 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache goes to the network if it has a stale 404 response. PASS
HTTP cache avoids going to the network if it has a fresh 404 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache goes to the network if it has a stale 410 response. PASS
HTTP cache avoids going to the network if it has a fresh 410 response. PASS
HTTP cache goes to the network if it has a stale 499 response. PASS
HTTP cache avoids going to the network if it has a fresh 499 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache goes to the network if it has a stale 500 response. PASS
HTTP cache avoids going to the network if it has a fresh 500 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache goes to the network if it has a stale 502 response. PASS
HTTP cache avoids going to the network if it has a fresh 502 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache goes to the network if it has a stale 503 response. PASS
HTTP cache avoids going to the network if it has a fresh 503 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache goes to the network if it has a stale 504 response. PASS
HTTP cache avoids going to the network if it has a fresh 504 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache goes to the network if it has a stale 599 response. PASS
HTTP cache avoids going to the network if it has a fresh 599 response. FAIL assert_less_than: Response used expected a number less than 2 but got 2
/fetch/http-cache/vary.html
Subtest Results Messages
OK
HTTP cache reuses Vary response when request matches. PASS
HTTP cache doesn't use Vary response when request doesn't match. PASS
HTTP cache doesn't use Vary response when request omits variant header. PASS
HTTP cache doesn't invalidate existing Vary response. FAIL assert_less_than: Response used expected a number less than 3 but got 3
HTTP cache doesn't pay attention to headers not listed in Vary. PASS
HTTP cache reuses two-way Vary response when request matches. PASS
HTTP cache doesn't use two-way Vary response when request doesn't match. PASS
HTTP cache doesn't use two-way Vary response when request omits variant header. PASS
HTTP cache reuses three-way Vary response when request matches. PASS
HTTP cache doesn't use three-way Vary response when request doesn't match. PASS
HTTP cache doesn't use three-way Vary response when request omits variant header. PASS

@ghost
Copy link

ghost commented Mar 14, 2017

View the complete job log.

Chrome (unstable channel)

Testing web-platform-tests at revision c3b1efa
Using browser at version 58.0.3029.19 dev
Starting 10 test iterations
All results were stable

All results

8 tests ran
/fetch/http-cache/304-update.html
Subtest Results Messages
OK
HTTP cache updates returned headers from a Last-Modified 304. PASS
HTTP cache updates stored headers from a Last-Modified 304. PASS
HTTP cache updates returned headers from a ETag 304. PASS
HTTP cache updates stored headers from a ETag 304. PASS
/fetch/http-cache/cc-request.html
Subtest Results Messages
OK
HTTP cache doesn't use aged but fresh response when request contains Cache-Control: max-age=0. PASS
HTTP cache doesn't use aged but fresh response when request contains Cache-Control: max-age=1. FAIL assert_equals: Response used expected 2 but got 1
HTTP cache doesn't use fresh response with Age header when request contains Cache-Control: max-age that is greater than remaining freshness. FAIL assert_equals: Response used expected 2 but got 1
HTTP cache does use aged stale response when request contains Cache-Control: max-stale that permits its use. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache does reuse stale response with Age header when request contains Cache-Control: max-stale that permits its use. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache doesn't reuse fresh response when request contains Cache-Control: min-fresh that wants it fresher. FAIL assert_equals: Response used expected 2 but got 1
HTTP cache doesn't reuse fresh response with Age header when request contains Cache-Control: min-fresh that wants it fresher. FAIL assert_equals: Response used expected 2 but got 1
HTTP cache doesn't reuse fresh response when request contains Cache-Control: no-cache. PASS
HTTP cache validates fresh response with Last-Modified when request contains Cache-Control: no-cache. PASS
HTTP cache validates fresh response with ETag when request contains Cache-Control: no-cache. PASS
HTTP cache doesn't reuse fresh response when request contains Cache-Control: no-store. FAIL assert_equals: Response used expected 2 but got 1
HTTP cache generates 504 status code when nothing is in cache and request contains Cache-Control: only-if-cached. FAIL assert_equals: Response status expected 504 but got 200
/fetch/http-cache/freshness.html
Subtest Results Messages
OK
HTTP cache reuses a response with a future Expires. PASS
HTTP cache does not reuse a response with a past Expires. PASS
HTTP cache does not reuse a response with a present Expires. PASS
HTTP cache does not reuse a response with an invalid Expires. PASS
HTTP cache reuses a response with positive Cache-Control: max-age. PASS
HTTP cache does not reuse a response with Cache-Control: max-age=0. PASS
HTTP cache reuses a response with positive Cache-Control: max-age and a past Expires. PASS
HTTP cache reuses a response with positive Cache-Control: max-age and an invalid Expires. PASS
HTTP cache does not reuse a response with Cache-Control: max-age=0 and a future Expires. PASS
HTTP cache does not prefer Cache-Control: s-maxage over Cache-Control: max-age. PASS
HTTP cache does not reuse a response when the Age header is greater than its freshness lifetime. PASS
HTTP cache does not store a response with Cache-Control: no-store. PASS
HTTP cache stores a response with Cache-Control: no-cache, but revalidates upon use. PASS
/fetch/http-cache/heuristic.html
Subtest Results Messages
OK
HTTP cache reuses an unknown response with Last-Modified based upon heuristic freshness when Cache-Control: public is present. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache does not reuse an unknown response with Last-Modified based upon heuristic freshness when Cache-Control: public is not present. PASS
HTTP cache reuses a 200 OK response with Last-Modified based upon heuristic freshness. PASS
HTTP cache reuses a 203 Non-Authoritative Information response with Last-Modified based upon heuristic freshness. PASS
HTTP cache reuses a 204 No Content response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache reuses a 404 Not Found response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache reuses a 405 Method Not Allowed response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache reuses a 410 Gone response with Last-Modified based upon heuristic freshness. PASS
HTTP cache reuses a 414 URI Too Long response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache reuses a 501 Not Implemented response with Last-Modified based upon heuristic freshness. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache does not use a 201 Created response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 202 Accepted response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 403 Forbidden response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 502 Bad Gateway response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 503 Service Unavailable response with Last-Modified based upon heuristic freshness. PASS
HTTP cache does not use a 504 Gateway Timeout response with Last-Modified based upon heuristic freshness. PASS
/fetch/http-cache/invalidate.html
Subtest Results Messages
OK
HTTP cache invalidates after a successful response from a POST PASS
HTTP cache does not invalidate after a failed response from an unsafe request PASS
HTTP cache invalidates after a successful response from a PUT PASS
HTTP cache invalidates after a successful response from a DELETE PASS
HTTP cache invalidates after a successful response from an unknown method FAIL assert_equals: Response used expected 3 but got 1
HTTP cache invalidates Location URL after a successful response from a POST FAIL assert_equals: Response used expected 3 but got 1
HTTP cache does not invalidate Location URL after a failed response from an unsafe request PASS
HTTP cache invalidates Location URL after a successful response from a PUT FAIL assert_equals: Response used expected 3 but got 1
HTTP cache invalidates Location URL after a successful response from a DELETE FAIL assert_equals: Response used expected 3 but got 1
HTTP cache invalidates Location URL after a successful response from an unknown method FAIL assert_equals: Response used expected 3 but got 1
HTTP cache invalidates Content-Location URL after a successful response from a POST FAIL assert_equals: Response used expected 3 but got 1
HTTP cache does not invalidate Content-Location URL after a failed response from an unsafe request PASS
HTTP cache invalidates Content-Location URL after a successful response from a PUT FAIL assert_equals: Response used expected 3 but got 1
HTTP cache invalidates Content-Location URL after a successful response from a DELETE FAIL assert_equals: Response used expected 3 but got 1
HTTP cache invalidates Content-Location URL after a successful response from an unknown method FAIL assert_equals: Response used expected 3 but got 1
/fetch/http-cache/partial.html
Subtest Results Messages
OK
HTTP cache stores partial content and reuses it. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache stores complete response and serves smaller ranges from it. FAIL assert_equals: Response status expected 200 but got 206
HTTP cache stores partial response and serves smaller ranges from it. FAIL assert_less_than: Response used expected a number less than 2 but got 2
HTTP cache stores partial content and completes it. FAIL assert_equals: expected (string) "bytes=5-" but got (undefined) undefined
/fetch/http-cache/status.html
Subtest Results Messages
OK
HTTP cache goes to the network if it has a stale 200 response. PASS
HTTP cache avoids going to the network if it has a fresh 200 response. PASS
HTTP cache goes to the network if it has a stale 203 response. PASS
HTTP cache avoids going to the network if it has a fresh 203 response. PASS
HTTP cache goes to the network if it has a stale 204 response. PASS
HTTP cache avoids going to the network if it has a fresh 204 response. PASS
HTTP cache goes to the network if it has a stale 299 response. PASS
HTTP cache avoids going to the network if it has a fresh 299 response. PASS
HTTP cache goes to the network if it has a stale 400 response. PASS
HTTP cache avoids going to the network if it has a fresh 400 response. PASS
HTTP cache goes to the network if it has a stale 404 response. PASS
HTTP cache avoids going to the network if it has a fresh 404 response. PASS
HTTP cache goes to the network if it has a stale 410 response. PASS
HTTP cache avoids going to the network if it has a fresh 410 response. PASS
HTTP cache goes to the network if it has a stale 499 response. PASS
HTTP cache avoids going to the network if it has a fresh 499 response. PASS
HTTP cache goes to the network if it has a stale 500 response. PASS
HTTP cache avoids going to the network if it has a fresh 500 response. PASS
HTTP cache goes to the network if it has a stale 502 response. PASS
HTTP cache avoids going to the network if it has a fresh 502 response. PASS
HTTP cache goes to the network if it has a stale 503 response. PASS
HTTP cache avoids going to the network if it has a fresh 503 response. PASS
HTTP cache goes to the network if it has a stale 504 response. PASS
HTTP cache avoids going to the network if it has a fresh 504 response. PASS
HTTP cache goes to the network if it has a stale 599 response. PASS
HTTP cache avoids going to the network if it has a fresh 599 response. PASS
/fetch/http-cache/vary.html
Subtest Results Messages
OK
HTTP cache reuses Vary response when request matches. PASS
HTTP cache doesn't use Vary response when request doesn't match. PASS
HTTP cache doesn't use Vary response when request omits variant header. PASS
HTTP cache doesn't invalidate existing Vary response. FAIL assert_less_than: Response used expected a number less than 3 but got 3
HTTP cache doesn't pay attention to headers not listed in Vary. PASS
HTTP cache reuses two-way Vary response when request matches. PASS
HTTP cache doesn't use two-way Vary response when request doesn't match. PASS
HTTP cache doesn't use two-way Vary response when request omits variant header. PASS
HTTP cache reuses three-way Vary response when request matches. PASS
HTTP cache doesn't use three-way Vary response when request doesn't match. PASS
HTTP cache doesn't use three-way Vary response when request omits variant header. PASS

@annevk
Copy link
Member

annevk commented Mar 15, 2017

These looks good to me, as does the change to the standard. Will you file browser bugs on failures or should I?

Also, you might want to consider using the .any.js convention to also test the HTTP cache from workers at close to no extra effort.

@mnot
Copy link
Member Author

mnot commented Mar 16, 2017

I'm happy to file bugs. Should I do that after the tests land, so I have something to point to (that's easier to run)?

WRT workers -- interesting. Do we think that the results will be any different? The cache behaviour should be the same.

@annevk
Copy link
Member

annevk commented Mar 16, 2017

Filing bugs after is fine. I think testing workers is good, since we often think they should behave the same, but then they don't because implementers took shortcuts because threading/processes is hard.

Firefox, Chrome and Safari pass. Will check Edge once checked in.
@annevk annevk merged commit 13062c6 into web-platform-tests:master Mar 23, 2017
annevk pushed a commit to whatwg/fetch that referenced this pull request Mar 23, 2017
In particular:

* Be more specific about terminology
* Detail more clearly how requests are to be modified

Tests: web-platform-tests/wpt#5137.

During review we decided to postpone #144 (poorly implemented if at all) and #307 (also poorly implemented despite security implications).

Fixes #336 and fixes #373.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants