jekyll-theme-chirpy icon indicating copy to clipboard operation
jekyll-theme-chirpy copied to clipboard

fix(pwa): avoid caching large files

Open MrMurdock11 opened this issue 1 year ago • 3 comments

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Improvement (refactoring and improving code)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Documentation update

Description

I'm going to try to solve an issue related to caching files that are chunked for transfer (usually they have a 206 status) that we have discussed here GH-1651. To avoid this error, we should only cache files that have a response code of 200.

image

MrMurdock11 avatar Apr 14 '24 12:04 MrMurdock11

@cotes2020 What do you think if I fix the 206 code to filter the request and finalize this PR, but create a new discussion to find a better solution?

MrMurdock11 avatar Apr 23 '24 13:04 MrMurdock11

@cotes2020 What do you think if I fix the 206 code to filter the request and finalize this PR, but create a new discussion to find a better solution?

I didn't elaborate on this much, but I have seen the problem in action as it causes errors for newly developed features and so should be fixed before release, I think.

Is there anything else we should fix except 206? I mean maybe it's a good idea to fix what we have discovered so far only?

kungfux avatar Apr 24 '24 11:04 kungfux

The comments I left above were mainly to get your opinions on whether there is a better solution.

Unless you have a better way, detecting whether the response status code is 206 is an acceptable solution.

If innerResponse’s status is 206, return a promise rejected with a TypeError.

Ref: https://w3c.github.io/ServiceWorker/#cache-put

cotes2020 avatar Apr 24 '24 13:04 cotes2020

@cotes2020 added the changes to your comment

MrMurdock11 avatar Apr 29 '24 13:04 MrMurdock11

~Sorry guys, I made a mistake while reviewing, returning directly after event.request.headers.has('range') is met would have the undesirable result that fontwesome styles could not be cached.~

~So, I'm going to rewrite this commit to fix this issue.~


Update:

Everything works fine, it's my browser extension that interferes with the test results, the Fontawesome icons can be cached correctly. Sorry for the disruption.

cotes2020 avatar Apr 30 '24 21:04 cotes2020

:tada: This PR is included in version 7.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar May 11 '24 07:05 github-actions[bot]