Forms with a service worker that precaches

I implemented a Netlify form. The form would submit, but I’d never see the success dialog, and my submissions weren’t showing up in my approved, or spam folders.

I was also using Workbox’s injectManifest in my Service Worker to precache all the static content of my site. Turns out that the SW was handling the form’s POST request to my page by serving a cached copy.

I disabled Workbox, but now my site doesn’t work offline anymore. A better solution might be to configure Workbox to only serve GET requests from the cache.

Has anyone else dealt with this?

BONUS POINTS: is it possible to have Netlify forms work offline as well? Maybe using Background Sync?

Hi, @jessehattabaugh, as this question is more about Workbox than it is about Netlify it is unlikely that our support team will have an answer for you.

It would be interesting to learn if anyone working with Workbox has found a solution for this. If you or anyone else does have have or find more information about this, I would certainly love to see the solution posted here.

1 Like

Hi! Doing a quick search (because I have the same problem with my Vue app with Service Worker). I found this article. You just have to add an action="/thank-you" attribute into the public/index.html and in your view.

You can see the complete solution here: [Support Guide] Form problems, form debugging, 404 when submitting