Firefox caching causing issues managing inline forms in Django

Hi there,

I’ve been using inline forms for a Django application (so essentially subforms within a parent form).

To manage those forms, the server send with the inline form a “management_form”, that contains informations such as:

<input type="hidden" name="details-TOTAL_FORMS" value="42" id="id_details-TOTAL_FORMS">
<input type="hidden" name="details-INITIAL_FORMS" value="5" id="id_details-INITIAL_FORMS">
<input type="hidden" name="details-MIN_NUM_FORMS" value="0" id="id_details-MIN_NUM_FORMS">
<input type="hidden" name="details-MAX_NUM_FORMS" value="1000" id="id_details-MAX_NUM_FORMS">

E.g. how many forms are currently in this inline formset, min/max numbers acceptable, etc. Then Django uses that to manage submissions server-side. I have an issue with FF (92.0 on Manjaro Linux) when I add some inline forms using javascript and do a page refresh (F5) without submitting the data. THe details of what happens can be found on this SO question.

Basically it seems that FF caches the old value of #id_details-TOTAL_FORMS. When the refresh is performed, the server renders that same input tag with the correct value="…" for the #id_details-TOTAL_FORMS. However, if the user added/removed inline forms (using javascript button), then it seems that FF remembers THAT value and overrides whatever the server resends.

This does NOT happen upon a hard refresh (ctrl shift r /ctrl f5). This also does NOT happen on Chrome.

Please see SO question for details, but… What specifically is causing this issue? I have tried setting an attribute autocomplete=“False” on that input tag, but it didn’t change anything.