-
I encountered an issue where if I import PDF files and try to open them via a link, the service worker prevents it from happening and keeps displaying the application. If I click unregister and refresh the page with the PDF URL, the PDF is displayed. How can I solve this problem? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The problem with PDF files:
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 You can also exclude any pdf from being intercepted by the precaching controller, add pdf extension to workbox: {
// <other options>
navigateFallbackDenylist: [/\.pdf$/],
} |
Beta Was this translation helpful? Give feedback.
The problem with PDF files:
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-handlingYou can also exclude any pdf from being intercepted by the precaching controller, add pdf extensi…