Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laracoft's avatar
Level 27

Can inertiajs let me load HTML without hitting PHP?

I'm planning for scalability, one of the concerns is that I would like is for some pages to load without ever hitting PHP.

Is it possible to achieve this using inertiajs?

  1. If yes, then my specific questions would be: how do I specify the route? Still in web.php?
  2. How do I include specific meta tags for SEO on these pages?
0 likes
20 replies
JussiMannisto's avatar

Laravel is written in PHP. You can't even bootstrap it without "hitting PHP", so you obviously can't use its router, let alone Inertia.

You could leverage CDNs for full-page caching, but those pages can't have dynamic data.

I'll cut to the chase: this is not a sensible way to scale up an app. PHP won't be the bottleneck.

There are real things you can do to improve performance. Optimize database queries. Cache results. Switch to Redis for caching, sessions and queues. Use a CDN. Add replicate DB servers, or more app servers with load balancing. Buy more powerful servers. Or go with some cloud service provider that does these things for you.

But chances are, you don't need to do much. You should fix actual issues, not imaginary ones.

JussiMannisto's avatar

If you absolutely need to cache entire pages in your app, Spatie has a package for that. It still uses PHP, though.

GdS's avatar

I agree with the previous answer, scaling involves a lot more than addressing PHP.

spatie/laravel-response-cache is excellent and very easy to setup. Alternatively, if your goal is to completely bypass PHP, for static / rarely updated pages I would consider inertia SSR + full page caching with josephsilber/page-cache

  1. It's still Laravel, so nothing changes at app level, just add a bit of server-level rules on top

  2. You may handle it however you prefer: with blade or in JS (provided SSR is enabled)

Again, If you really need to scale bigger, these approaches are not enough.

Hope it helps.

laracoft's avatar
Level 27

Well, thanks I take the answer to be not achievable with Inertiajs.

I come from the angle where if I do it with Vue, I know and can control specifically where PHP gets involved, so I'm asking the same question of inertiajs.

It is not an imaginary problem, I see it happening already and I'm planning for the future.

laracoft's avatar
Level 27

@Snapey

If I use just vite and vue, it gets there through index.html. But I think you already know that.

Snapey's avatar

@laracoft ok. If you create a folder for static pages, they should be ignored by your .htaccess and served directly by the webserver

laracoft's avatar
Level 27

@Snapey yea that's what I'm already doing, and it's all acceptable with just 2 pain points: meta tags (SEO) and route names

Snapey's avatar

@laracoft why? These are static pages. Just set what you need directly in thefile

Snapey's avatar

@laracoft Sorry, you are not making any sense, so Im out of this discussion

jaseofspades88's avatar

You have to ask yourself... 'Am I really asking the right question?' as there is no reason why you wouldn't want all of the security measures out of the box with Laravel. If you're simply trying to serve some static HTML, what's the benefit of serving it 'without PHP'?

jlrdw's avatar

@laracoft inertiajs as you know is for an SPA. But as far as code goes, it still travels to the back end fetched and travels to the static front end.

Very similar to using regular JS and Fetch JS if rendering a partial page reload. Technically what you see on the front end is actually nothing but static data waiting to be acted on one way or the other.

It will still work the same whether JS or just plain blade is used. You still have kind of a page reload meaning new data replaces old data. In fact it's not much difference in load times in many SPA's verses full page reloads, granted a little faster.

Like mentioned above, and to rephrase, how your database is setup will usually make the big difference.

  • only query what's needed
  • index where needed
  • purge out old data when you can (archive)
  • load balance when needed
  • paginate server side
  • don't put tens of thousands of records in a collection (too slow)
  • learn to let the database do it's job.
  • learn when to use relations verses joins and groupby
  • avoid the n + 1 problem
  • etc
1 like
laracoft's avatar
Level 27

@jlrdw

These specific pages host interactive Vue components that do not require any backend.

jlrdw's avatar

@laracoft You are describing a desktop app that is not even on a server..

Otherwise if the application is on a server and a user does these things in their browser then it has a back end.

Edit:

Even if you had a purely browser based javascript CAD program as an example, used right on your PC, not on a server, it is still static data that depends on the parent program to run like C++. All browser data is static until a command (button action, click) or whatever makes something happen.

laracoft's avatar
Level 27

@jlrdw

Well, take for example a PWA Excel: simplified, 90% of the features don't require a connection to backend, but we can't discard the remaining 10% that needs a backend, e.g. payment/auth etc, and call it "not even on a server"

Does it still make sense that 100% of our requests to the server must go through PHP?

To make only 10% of the requests go through PHP, I had to use vite + vue + axios, creating routing and SEO problems.

The reason I'm asking on Laracast is because Laravel makes this 10% a total breeze, something which I don't want to lose.

Niush's avatar

@laracoft With Inertia.js you lose some, you win some. You will not have to worry about frontend routing, authorization, authentication, manual API and state management, etc.

But, if you really need a PWA (or just a front-end heavy application), then you have to go with vite + vue + axios standalone SPA (nothing wrong with that).

Sanctum cookie based auth is easy, and you can also find many monolithic starter kits like this.

JussiMannisto's avatar

@laracoft If you want that, then write a Vue SPA with front-end routing. Install Laravel as an API, and call it only when needed. I fail to see the issue.

If you want server-side rendered SEO tags, then you must use some server-side renderer like PHP or Node. You can't have your cake and eat it too.

It is not an imaginary problem, I see it happening already and I'm planning for the future.

I have two basic questions:

  1. How many requests per second does your app get during peak times?
  2. How have you determined that booting Laravel is the cause of your performance issues?
jlrdw's avatar

@laracoft

90% of the features don't require a connection to backend

Every action requires a back end. If you add two numbers directly in say excel the .exe and any related .dll files are the back end. There is no such thing as an app without a back end.

Can you explain what you are trying to do with your app?

I have had all kinds of apps with A/R, A/P, Payroll, etc and never worried about such things.

Please or to participate in this conversation.