FIO-9006: Fixed cached grid responses #1104
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to Jira Ticket
https://formio.atlassian.net/browse/FIO-9006
Description
Issue: When the grid requests forms from the API server, the server generates an
ETag
header for the response. The browser uses thisETag
with theIf-None-Match
header in subsequent requests so the server can validate if the content has changed. If not, it returns a304 Not Modified
status, indicating to the browser to use the cached version of the response.Example: When the grid already has 1 page with the total items equal to the maximum items per page to show, and the user tries to add a new form that should be displayed on the second page of grid items, the following issue occurs:
If-None-Match
header.Content-Range
header because a new form was added.ETag
only considers the body of the response and not the headers.ETag
, which matches theIf-None-Match
request header.304 Not Modified
status, and the browser uses the cached version of the response with the oldContent-Range
header.Content-Range
header to display pagination correctly. In this case, the user does not see the new available page in the pagination.Solution: Based on the fresh function, we can use the
Cache-Control
request header with theno-cache
value to force the Express server not to return a304 Not Modified
status. This ensures the server sends the updated response with the correctContent-Range
header, allowing the grid to display the correct pagination.How has this PR been tested?
Manually
Checklist: