Start your All-Access Pass to unlock this challenge
In our video, why do we have to add Turbo.clearCache(); to our turbo:before-fetch-response event handler?
Turbo.clearCache();
turbo:before-fetch-response
Because by doing event.preventDefault(); in the line before, we're preventing Turbo from clearing its cache after a form successfully submitted.
event.preventDefault();
Because we need to make sure that after our form submits, the pages will load from scratch so that they show the reflected changes (Turbo does not do this on its own)
Because it's always a good practice to clear the Turbo cache before we call Turbo.visit() so that we always get a fresh page.
Turbo.visit()
Because Turbo has a bug when sometimes it doesn't properly clear the cache after a form was successfully submitted.