Set no-cache headers on datagrid initial response.

Review Request #13750 — Created April 18, 2024 and submitted

Information

Djblets
release-5.x

Reviewers

We already were setting the proper Cache-Control headers for the
datagrid listview, which is used for inline reloading of the datagrid
contents. Unfortunately, we didn't have matching headers for the
datagrid pages themselves. This was mostly not noticeable, except for
one highly annoying thing: if you selected a checkbox and then clicked
an action (such as archive), the action would run and everything would
look fine. If the page was then reloaded, Firefox would very helpfully
try to re-select checkbox in the same row number, even though that
didn't correspond to the one that was checked and archived. Setting the
cache headers (in particular, Cache-Control: no-store) turns off this
behavior in Firefox.

While I was doing this I replaced the existing code with Django's
add_never_cache_headers, which does the same thing with less
verbosity.

  • Ran unit tests.
  • Selected a review request and clicked "Archive" in the actions
    sidebar. Saw the datagrid update as expected. Clicked the reload
    button in the browser, and saw that Firefox no longer tried to select
    any checkboxes.
Summary ID
Set no-cache headers on datagrid initial response.
We already were setting the proper `Cache-Control` headers for the datagrid listview, which is used for inline reloading of the datagrid contents. Unfortunately, we didn't have matching headers for the datagrid pages themselves. This was mostly not noticeable, except for one highly annoying thing: if you selected a checkbox and then clicked an action (such as archive), the action would run and everything would look fine. If the page was then reloaded, Firefox would very helpfully try to re-select checkbox in the same row number, even though that didn't correspond to the one that was checked and archived. Setting the cache headers (in particular, `Cache-Control: no-store`) turns off this behavior in Firefox. While I was doing this I replaced the existing code with Django's `add_never_cache_headers`, which does the same thing with less verbosity. Testing Done: - Ran unit tests. - Selected a review request and clicked "Archive" in the actions sidebar. Saw the datagrid update as expected. Clicked the reload button in the browser, and saw that Firefox no longer tried to select any checkboxes.
540ec38397fba25cbc2a6a8734a40e2461c9227e
maubin
  1. Looks good, you should check that the correct behaviour happens in Chrome too just in case.

  2. 
      
chipx86
  1. Ship It!
  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.x (de89c14)