Django ERR_CACHE_MISS on login page after clicking a link and back

405 Views Asked by At

I have a login page with a form with username and password fields and a submit button. In the same page there are links to other pages on the site.

I'm using the vanilla Django login view. The user can login using the correct credentials, otherwise the login form shows authentication error as expected. Everything works fine so far. The issue I'm having is reproducible this way:

  1. go to login page and input wrong credentials, submit
  2. correctly validation errors appear on the form
  3. click some link on the page
  4. correctly the browser brings me on the other page following the GET request
  5. click on browser go back button

Or, another way:

  1. go to login page and input wrong credentials, submit
  2. correctly validation errors appear on the form
  3. click on browser go back button
  4. click on browser go forward button

At this point I get this message from the browser:

Confirm Form Resubmission

This webpage requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press the reload button to resubmit the data needed to load the page. ERR_CACHE_MISS

It's weird, but even more weird is that if I check on Disable cache in Chrome DevTools Network panel, the problem disappears (ie. when I click back, I see the form precompiled with previously inserted data). So I tried to add the never_cache decorator to LoginView just to see, but then realized this view (obviously) already has the decorator applied.

I wonder what the problem is and how to solve it.

0

There are 0 best solutions below