<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                > http 狀態碼和http methods,僅僅使一個約束規范。可以更改(不建議) ### http 狀態碼 * 狀態碼分類 * 1xx:服務器收到請求 * 2xx:請求成功,如 200 * 3xx:重定向,如 302 * 4xx:客戶端錯誤,如 404 * 5xx:服務端錯誤,如 500 * 常用狀態碼 * 200 成功 * 301 永久重定向 配合 location,瀏覽器自動處理。如換域名,瀏覽器會存緩存。 * 302 臨時重定向 配合 location,瀏覽器自動處理。如搜索引擎的跳轉鏈接、短網址的跳轉。 * 304 資源未被修改,兩次請求的內容是相同的 * 404 資源未找到 * 404 沒有權限 * 500 服務器錯誤 * 504 網關超時 ### http methods * 傳統 methods * get 獲取服務器的數據 * post 向服務器提交數據 * 現在的 methods * get 獲取數據 * post 新建數據 * patch/put 更新數據 * delete 刪除數據 ### Restful API * 一種新的 API 設計方法(早已推廣使用) * 傳統 API 設計:把每個 url 當做一個功能 * Restful API 設計:把每個 url 當做一個唯一的資源 #### 如何設計成一個資源? * 盡量不用 url 參數 * 傳統 API 設計:`/api/list?pageIndex=2` * Restful API 設計:`/api/list/2` * 用 method 表示操作類型 * 傳統 API 設計,如 * post 請求 `/api/create-blog` 創建博客 * post 請求 `/api/update-blog?id=100` 更改博客內容 * get 請求 `/api/get-blog?id=100` 獲取博客內容 * Restful API * post 請求 `/api/blog` 新建博客 * patch 請求 `/api/blog/100` 更新博客 * get 請求 `/api/blog/100` 獲取博客內容 ### http headers * 常見的 Request Headers:請求頭 * ![image-20210307142126063](https://image.mdashen.com/pic/image-20210307142126063.png) * Accept:瀏覽器可接收的數據格式 * Accept-Encoding 瀏覽器可接收的壓縮算法,如 gzip * Accept-Languange 瀏覽器可接收的語言,如 zh-CH * Connection: keep-alive 一次 TCP 連接重復使用 * User-Agent:簡稱UA,瀏覽器信息 * Content-type 發送數據的格式,如 application/json * 常見 Response Headers:響應頭 * ![image-20210307142233196](https://image.mdashen.com/pic/image-20210307142233196.png) * Content-type 返回數據的格式,如 application/json * Content-length 返回數據的大小,多少字節 * Content-Encoding 返回數據的壓縮算法,如 gzip * 自定義 header:如,Authentication;常用語接口鑒權 * 緩存相關的 headers * ![image-20210307195941177](https://image.mdashen.com/pic/image-20210307195941177.png) ### http 緩存 ![image-20210307210410090](https://image.mdashen.com/pic/image-20210307210410090.png) #### http 緩存-強制緩存 ![image-20210307203735748](https://image.mdashen.com/pic/image-20210307203735748.png) ![image-20210307203900106](https://image.mdashen.com/pic/image-20210307203900106.png) ##### Cache-Control * Response Headers 中 * 控制強制緩存的邏輯 * 例如:cache-control: max-age=2592000 單位是秒 * cache-control的值 * **max-age**:緩存的最大過期時間 * **no-cache**:不用強制緩存,交給服務端處理 * no-store:不緩存,讓服務端再次返回 * private:用戶緩存 * public:允許中間路由、代理進行緩存 ###### Expires * 同在 Response Headers 中 * 同為控制緩存過期 * 已被 Cache-Control 代替 #### http緩存-協商緩存(對比緩存) ![image-20210307204931779](https://image.mdashen.com/pic/image-20210307204931779.png) * 服務端緩存策略,服務端判斷這個文件是否需要緩存 * 服務器判斷客戶端資源,是否和服務端資源一樣 * 一致則返回 304 ,負責返回 200 和最新的資源 ##### 資源標識 * 在 Response Headers 中,有兩種 * last-Modified 資源的最后修改時間 * Etag 資源的唯一標識(一個字符串,類似人類的指紋) * 兩者會優先使用 Etag * Last-Modified 只能精確到秒級 * 如果資源被重復生成,而內容不變,則 Etag 更精確 ##### Last-Modified ![image-20210307205350512](https://image.mdashen.com/pic/image-20210307205350512.png) ##### Etag ##### ![image-20210307205627943](https://image.mdashen.com/pic/image-20210307205627943.png) #### 刷新頁面對緩存的影響 ##### 三種刷新方式 * 正常操作:地址欄輸入url、跳轉鏈接、前進后退 * 手動刷新:F5、點擊刷新按鈕、右擊菜單刷新 * 強制刷新:ctrl + F5 ##### 不同刷新操作、不同緩存策略 * 正常操作:強制緩存有效,協商緩存有效 * 手動刷新:強制緩存失效,協商緩存有效 * 強制刷新:強制緩存失效,協商緩存失效
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看