question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cached response return non-inertia response

See original GitHub issue

Versions:

"@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:open
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
renepardoncommented, Dec 16, 2021

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.

0reactions
jez500commented, Feb 21, 2022

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 with public and max-age breaks inertia due to the same url being used for html and XHR requests

What 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found