Cached response return non-inertia response
See original GitHub issueVersions:
"@inertiajs/inertia": "^0.10.0",
"@inertiajs/inertia-vue3": "^0.5.1",
"@inertiajs/progress": "^0.2.6",
Describe the problem: / Steps to reproduce
Because #154 is closed already
I had the same issue yesterday and I can confirm, that when using spatie/laravel-varnish which provides the cachable middleware. Within this middleware the cache header is set to public with a max-age of 60*24*26
. After removing this header and cleaning up the browser cache completely, everything works as expected. With a cache header set, the response gets converted to a non-inertia respones and therefore it opens in an iframe rather than within the existing DOM.
Question/Suggestion
Right now, the SSR is not yet available to the public but will it be possible to use cached responses with SSR? That would help a lot.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Cached response return non-inertia response · Issue #154 · inertiajs ...
My Inertia app sometimes showing a modal with an iframe instead of changing the page when I click a link. I heard that...
Read more >InertiaJS Form Responses opening in Modal, with a quick ...
This is just a simple form component with some Laravel validation, and it just makes an API request and returns an error or...
Read more >Everything You Need to Know About Laravel Caching - Kinsta
Learn how to increase software performance and scalability by implementing and manipulating the right caching strategy in Laravel.
Read more >Response caching in ASP.NET Core - Microsoft Learn
On responses: A cache must not store any part of the response. ... The first request is returned by the server and cached...
Read more >Cache always returns NULL - Laracasts
Update: I just noticed that it's not always returns null, sometimes it works. ... don't need to provide it if I want to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s just about a micro optimization to prevent additional round trips to the laravel framework/backend at all because static pages don’t change frequently, so I can deliver them immediately through Varnish. For all the other pages which have database requests and dynamic contents I agree that the gzipped JSON response is totally enough and if not I can cache the DB results.
Following this as I have a similar issue, I want to use a CDN that relies on the
cache-control
header to know if a page is cacheable, but it seems that using cache-control withpublic
andmax-age
breaks inertia due to the same url being used for html and XHR requestsWhat could potentially solve this is if inertia appended a change to the url. Eg a query parameter such as
?format=json
If anyone comes across any other solutions, I’d love to know