選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

cacheOkAndOpaquePlugin.mjs 1009 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. Copyright 2016 Google Inc. All Rights Reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. import '../_version.mjs';
  14. export default {
  15. /**
  16. * Return return a response (i.e. allow caching) if the
  17. * response is ok (i.e. 200) or is opaque.
  18. *
  19. * @param {Object} options
  20. * @param {Response} options.response
  21. * @return {Response|null}
  22. *
  23. * @private
  24. */
  25. cacheWillUpdate: ({response}) => {
  26. if (response.ok || response.status === 0) {
  27. return response;
  28. }
  29. return null;
  30. },
  31. };