Caching in HTTP

  • 5,125 views
Uploaded on

初探 HTTP 1.1 Cache 機制,透過簡單的實驗來說明瀏覽器對於 HTPP Cache 的實作策略。

初探 HTTP 1.1 Cache 機制,透過簡單的實驗來說明瀏覽器對於 HTPP Cache 的實作策略。

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,125
On Slideshare
0
From Embeds
0
Number of Embeds
5

Actions

Shares
Downloads
10
Comments
0
Likes
7

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Caching in HTTP SJ 2016/07/25 Email: sj@toright.com Blog: http://blog.toright.com
  • 2. 回顧 HTTP 1.1 的設計理念 Architectural Styles and the Design of Network-based Software Architectures (by Roy Thomas Fielding) CHAPTER 5. Representational State Transfer (REST)
  • 3. HTTP Features ● HTTP 1.1 設計 Cache 的目的在降低 Request 與 Full Response ● 以下兩個主要的設計理念 ○ Expiration ○ Validation ● 實作上透過 Header 讓 Server 與 Client 可以 自由定義 Cache 的方式
  • 4. HTTP 1.0 與 HTTP 1.1 Caching Difference HTTP 1.0 Reponse Cache Header ○ Expires ○ Pragma HTTP 1.1 Reponse Cache Header ○ Cache-Control
  • 5. 介紹 HTTP 1.1 Cache-Control Header ● Response Cache Header ○ ○ ○ ○ ○ ○ ● no-store 完全不 Cache no-cache 允許 Cache 但是每次都會檢查 Cache 狀態 max-age 設定要 Cache 幾秒 private Cache 只給目前使用者使用 public Cache 可共用 (HTTPS不可共用) must-revalidate 交由 Client 自行決定要不要使用 Cache 可以混搭
  • 6. 如何檢查 Cache 是否有效? ● 時間導向 (秒為單位) Last-Modified / If-Modified-Since ● 檔案內容導向 (Hash) ETag / If-None-Match
  • 7. Cache-Control: no-store
  • 8. Cache-Control: no-cache
  • 9. Cache-Control: max-age
  • 10. Cache-Control: private
  • 11. Cache-Control: public
  • 12. Cache-Control: must-revalidate
  • 13. Reference ● HTTP 1.1 RFC 2616 - 14.9 Cache-Control ● HTTP 1.1 RFC 2616 - 13 Caching in HTTP ● Architectural Styles and the Design of Network-based Software Architectures - 5 Representational State Transfer (REST)
  • 14. The End Thanks! Email: sj@toright.com Blog: http://blog.toright.com