inertia-rails
inertia-rails copied to clipboard
`Vary` header should be included in all Inertia responses
Hi! I've stumbled upon a very specific error when an Inertia page is served from the browser cache:
- First, HTML page is accessed, response is cached
- Then, a partial reload on the same URL, expecting a Inertia JSON response (with
X-Inertia
header) - Inertia gets served first HTML, errors and shows response inside a modal
Taking a look at the InertiaRails::Renderer
, it seems that the Vary
header that would prevent this from happening is only added for subsequent X-Inertia
Inertia responses – and so the browser still uses the first response for all cache hits.
I'm testing a monkey-patch fix on my app and could open a PR if this is the correct diagnosis.