Henry Johnson
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- tags: React, Next.js --- # Tech sharing: ## :memo: todo list 1. What’s http request/response ? 2. What’s server/client side render ? 3. Why we need Next.js ? 4. Functional Javascript ### 1. What's http request/response? HyperText Transfer Protocol 縮寫:HTTP HTTP的發展是由提姆·柏內茲-李於1989年在歐洲核子研究組織(CERN)所發起。 https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol *HTTP 就是一套網路傳輸協定,而今天要學的就是這套協定的內容是什麼,以及如何實作一個簡單的 Client 與 Server 端。要了解全球通訊網的基礎,才有辦法依照標準來實作網站。* Client & Server 一般來說傳輸資料的兩端會分為 客戶端 ( Client ) 跟 伺服器端 ( Server ) Client: 以網頁來說就是你的瀏覽器、電腦,主要會發送 「 請求 request 」到 Server 端 Server: 收到 request 開始處理資料,完成後會回傳 「回應 response 」到 Client 端 傳統的瀏覽網頁的方法(server side render) 1. 使用者透過瀏覽器(Chrome, IE, Brave...) 2. 輸入網址 (過程會經過網路層,在此不贅述) 3. 透過http協議發送請求給伺服器 4. 伺服器將製作好的網頁(.html file)Response 給瀏覽器 5. 瀏覽器載入取得的html網頁 6. 使用者就可以看到網頁囉 補充: 伺服器是甚麼呢?想像就是一台只做特定事情的電腦 現代的做法(client side render) 1. 直接載入html的框 2. 透過JavaScript發送http request 3. 取得JSON格式的資料 4. 透過JavaScript將純粹的資料放入html中該放的位置 瀏覽器主要做的事情: 1.進行解析 html、css、js、圖片檔案…等等,渲染成可讀性高的網頁內容 補充資料: 1. https://medium.com/pierceshih/%E7%AD%86%E8%A8%98-%E4%BD%95%E8%AC%82-http-%E5%82%B3%E8%BC%B8%E5%8D%94%E5%AE%9A-1d9b5be3fd24 2. https://yakimhsu.com/project/project_w4_Network_http.html ### 2. What's server/client side render? 1. Pure server side render 1) 在後端取得所需資料後,把完整的HTML組成 2) 傳回瀏覽器 ![](https://i.imgur.com/Y5pRHG4.png) 透過伺服器端渲染能讓 SEO 效果不錯,但是使用者體驗較不佳 Framework type: PHP(Lareval) JSP(Spring) .NET Node.js(Express, Kao) 範例:https://www.nkust.edu.tw/index.php 2. Pure client side render 1) 只會有一頁html, 製作組成內容都靠JavaScriptt ![](https://i.imgur.com/S9VcqRR.png) 2.1 CSR - Client-Side Rendering(客戶端渲染) 渲染過程全部交給 Client 端的瀏覽器去處理,Server 端不參與任何渲染。一開始的 HTML 是空白的,需要等待 JavaScript 下載並執行後瀏覽器才會顯示畫面。 優點 1. 減少 Server 端的壓力因為 JavaScript 及 CSS 在第一次都已經發送到 Client 端,之後只需要向 Server 端取得相關頁面的 data 即可。 2. 頁面切換速度快 `因為 HTML 頁面都是 Client 端自己編譯的,所以頁面切換時不需要像 SSR 等待 Server 端回傳 HTML;而且網頁內容的改變通常都是局部的,這樣就避免了不必要的跳轉及重複渲染。` 缺點 1. 首屏顯示慢,明明首頁只有一點內容卻下載了所有頁面的資源。 2. SEO 較差 `因爲一開始的 HTML 頁面是空白的;儘管現在 Google 的爬蟲也會等 JavaScript 編譯好再爬,但這塊對 SEO 的實際幫助還需要時間驗證。` 應用場景 1. 會高頻操作且不需 SEO 的網站 2. 像是社群網站(Facebook, IG),如果這類型的系統採取 SSR 會造成 Server 端較大的負荷。 4.2 SSR - Server-Side Rendering(伺服器端渲染) HTML 由 Server 端編譯出來返回 Client 端,所以 Client 看到的畫面就是最終版 HTML。 優點 1. SEO 排名更高 2. 因為 Google 爬蟲可以直接抓到網站的資訊。 3. 首屏渲染快 `因為不需要下載一堆 JavaScript 及 CSS ,還要等待它們編譯後才看到頁面。 減少 Client 端的耗電量,因為編譯的步驟都在 Server 端執行。` 缺點 1. Server 端承受比較大的壓力 2. 由於頁面都是在 Server 端進行編譯,在高併發場景中會消耗相當大的資源。 應用場景 低頻操作但需要 SEO 優化的網站 像是媒體類型的網站(部落格、新聞網站、技術文件),因為文章要被搜尋到才會有流量及話題,而且大部分的時候 Client 端都在閱讀,很少有高頻操作的情境。 Framework : React.js, Angular.js, Vue.js https://www.facebook.com/ ### 3. Why we need Next.js ? Next.js 是 React 的 SSR 框架,Vue 也有類似的 SSR 框架叫做 Nuxt,如果要一句話解釋它們為什麼存在: ## 自己實作 SSR 真的太痛苦了!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully