inertia-rails icon indicating copy to clipboard operation
inertia-rails copied to clipboard

`Vary` header should be included in all Inertia responses

Open ariel-codes opened this issue 7 months ago • 0 comments

Hi! I've stumbled upon a very specific error when an Inertia page is served from the browser cache:

  1. First, HTML page is accessed, response is cached
  2. Then, a partial reload on the same URL, expecting a Inertia JSON response (with X-Inertia header)
  3. 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.

ariel-codes avatar Jul 10 '24 22:07 ariel-codes