Client-side or server-side processing?

前端 未结 6 712
逝去的感伤
逝去的感伤 2021-02-05 10:22

So, I\'m new to dynamic web design (my sites have been mostly static with some PHP), and I\'m trying to learn the latest technologies in web development (which seems to be AJAX)

6条回答
  •  伪装坚强ぢ
    2021-02-05 10:47

    Congratulations for moving to dynamic sites! I would say the following conditions have to be met for you to do client-side layout (it goes without saying that you should always be doing things like filtering DB queries and controlling access rights server side):

    • Client browser and connection capabilities are up to snuff for the vast majority of use cases
    • SEO and mobile/legacy browser degradation are not a big concern (much easier when you synthesize HTML server side)

    Even then, doing client-side layout makes testing a lot harder. It also produces rather troublesome synchronization issues. With an AJAX site that loads partials, if part of the page screws up, you might never know, but with regular server-side composition, the entire page is reloaded on every request. It also adds additional challenges to error/timeout handling, session/cookie handling, caching, and navigation (browser back/forward).

    Finally, it's a bit harder to produce perma-URLs in case someone wants to share a link with their friends or bookmark a link for themselves. I go over a workaround in my blog post here, or you can have a prominent "permalink" button that displays a dynamically rendered permalink.

    Overall, especially when starting out, I would say go with the more kosher, better supported, more tutorialed, traditional approach of putting together the HTML server side. Then dip in some AJAX here and there (maybe start out with form validation or auto-completion), and then move on up.

    Good luck!

提交回复
热议问题