Coder Social home page Coder Social logo

Comments (5)

georgehanson avatar georgehanson commented on July 19, 2024 2

It sounds more like something that would be on the client side. Perhaps on the client side you could do something like $inertia.clear('auth') which will remove it from the request header to the backend. So from the servers point of view it would return the data.

from inertia-laravel.

georgehanson avatar georgehanson commented on July 19, 2024

I can see why this might be useful.

One thing to consider would be how to "re-share" information that you have shared with the proposed shareOnce method.

For example, if you are sharing user details the once and they updated their username, email, name etc you would want that to then be re-shared. So in that instance the implementation would need to overrule the request header saying that the information is already on the client side.

from inertia-laravel.

gzhihao avatar gzhihao commented on July 19, 2024

yep, re-share is a bit tricky, not sure if there is an elegant solution.

from inertia-laravel.

gzhihao avatar gzhihao commented on July 19, 2024

@reinink would like to know your thoughts on it.

from inertia-laravel.

reinink avatar reinink commented on July 19, 2024

Hey folks! My gut reaction is that this feels like too much complexity for what you gain in performance. Passing the currently authenticated user on each request is adding very little overhead, and typically this shared data is pretty minimal.

For most apps it will include:

  1. The current user
  2. Flash data (only when they exist)
  3. Errors (only when they exist)

I like to think of Inertia like a server-side framework. With a classic server-side framework, literally each page load you send the entire site template on each request, which includes the currently authenticated user (ie. in the header). And, that's a totally accepted way of doing things. So passing a little extra JSON in each Inertia request seems fine too. In fact, it's obviously way better than a classic server-side rendered app, since the entire template isn't being resent each time.

This is something we can always revisit in the future. 💪

from inertia-laravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.