• ☆ Yσɠƚԋσʂ ☆OP
    link
    fedilink
    107 months ago

    With the SPA approach, you can have remarkably little state on the server because all the state associated with the user session lives on the frontend. The value of doing this obviously depends on the type application you’re making, but it can be a sensible approach in some cases.

      • ☆ Yσɠƚԋσʂ ☆OP
        link
        fedilink
        47 months ago

        Sure, but that only gets you so far. I think it’s important to distinguish between document sites where the users mostly just views content, and actual applications like an email client or a calendar. The former can be easily handled with little to no frontend code, however the latter tend to need non trivial amount of UI state management.

    • @areyouevenreal@lemm.ee
      link
      fedilink
      -17 months ago

      Doesn’t SPA require polling the web server for more information? I feel like any website which retains information outside of the client device (like anything with a login page) would require state to be stored somewhere on the backend.

      • @bitfucker@programming.dev
        link
        fedilink
        47 months ago

        What kind of polling are we talking about? If you are talking about realtime data, SSE doesn’t solve that either. You need SSE or WebSocket for that (maybe even WebRTC). If what you mean is that every time the page is refreshed then the data is reloaded, it is no different than polling.

      • ☆ Yσɠƚԋσʂ ☆OP
        link
        fedilink
        37 months ago

        Typically, you just have a session cookie, and that doesn’t even need to be part of the app as auth can be handled by a separate proxy. The server just provides dumb data pull operations to the client in this setup, with all the session state living clientside.

        • @areyouevenreal@lemm.ee
          link
          fedilink
          -17 months ago

          That data has to be stored somewhere though. So you would still need some kind of database server to store it all or some other solution. That’s what I mean by outsourcing state. Data is still stored in the backend, just in a database rather than a web server.

          • ☆ Yσɠƚԋσʂ ☆OP
            link
            fedilink
            -17 months ago

            There is data that gets persisted and needs to be stored somewhere, and then there’s the UI state that’s ephemeral. The amount of data that gets persisted tends to be small, and the logic around it is often trivial.

                • @areyouevenreal@lemm.ee
                  link
                  fedilink
                  -17 months ago

                  How am I being obtuse? You have been trying to trivialise the backend and now frontend as well. Backend isn’t just writing PHP or whatever, it’s setting up database servers, authentication proxies, and all that stuff. Not everything can be stateless.

                  • ☆ Yσɠƚԋσʂ ☆OP
                    link
                    fedilink
                    37 months ago

                    I’m not trivializing anything here. What I actually said was that when all the UI logic lives on the frontend, then the backend just has dumb fetch and store operations along with an auth layer. In this scenario, the backend code can indeed be largely stateless. Specifically, it doesn’t care about the state of the user session or the UI. The only one trivializing things here is you by completely ignoring the nuance of what’s being explained to you.