Skip to content

how to handle pdf files inside assets? #723

Answered by userquin
lorof asked this question in Q&A
Discussion options

You must be logged in to vote

The problem with PDF files:

  • you don't have them in the sw precaching strategy
  • when requesting th epdf file, the service worker will try to find it in the precaching cache, since pdf files are missing the sw will serve the fallback page (html)

You can add the PDF files to the precaching cache or you can exclude them from sw precaching handler:

are PDF files static? if so, you can add them to the sw precache (add pdf extension to includeAssets pwa config option), this way pdf can be downloaded when offline: check https://vite-pwa-org.netlify.app/guide/static-assets.html#static-assets-handling

You can also exclude any pdf from being intercepted by the precaching controller, add pdf extensi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lorof
Comment options

Answer selected by lorof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants