Re: [w3c/ServiceWorker] Remove incumbent/fetching record from Cache behavior (#1190)

jungkees commented on this pull request.



>                    1. If |operation|.{{CacheBatchOperation/type}} matches "put", then:
                       1. If |operation|.{{CacheBatchOperation/response}} is null, <a>throw</a> a <code>TypeError</code>.
                       1. Let |r| be |operation|.{{CacheBatchOperation/request}}'s associated [=Request/request=].
                       1. If |r|'s [=request/url=]'s [=url/scheme=] is not one of "<code>http</code>" and "<code>https</code>", <a>throw</a> a <code>TypeError</code>.
                       1. If |r|'s [=request/method=] is not \`<code>GET</code>\`, <a>throw</a> a <code>TypeError</code>.
                       1. If |operation|.{{CacheBatchOperation/options}} is not null, <a>throw</a> a <code>TypeError</code>.
-                      1. Set |requestResponseArray| to the result of running <a>Query Cache</a> algorithm passing |operation|.{{CacheBatchOperation/request}}.
-                      1. If |requestResponseArray| is not an empty array, then:
-                          1. Let |requestResponse| be |requestResponseArray|[0].
-                          1. Let |fetchingRecord| be the corresponding <a>fetching record</a> for |requestResponse|[0] and |requestResponse|[1] in <a>request to response map</a>.
-                          1. Set |fetchingRecord|.\[[key]] to |operation|.{{CacheBatchOperation/request}} and |fetchingRecord|.\[[value]] to |operation|.{{CacheBatchOperation/response}}.
-                      1. Else:
-                          1. Set a newly-created <a>fetching record</a> {\[[key]]: |operation|.{{CacheBatchOperation/request}}, \[[value]]: |operation|.{{CacheBatchOperation/response}}} to <a>request to response map</a>.
-
-                          Note: The cache commit is allowed as long as the response's headers are available.
-
+                      1. Set |requestResponseList| to the result of running [=Query Cache=] with |operation|.{{CacheBatchOperation/request}}.
+                      1. If |requestResponseList| [=list/is not empty=], [=list/replace=] the [=list/item=] of |cache| that matches |requestResponseList|[0] with |operation|.{{CacheBatchOperation/request}}/|operation|.{{CacheBatchOperation/response}}.

I addressed it as you suggested. I think we still can do better for the return value of Batch Cache Operations somehow. I'll look into it as a separate work.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1190#discussion_r141596035

Received on Thursday, 28 September 2017 11:53:01 UTC