SlideShare a Scribd company logo
1 of 14
Download to read offline
Caching in HTTP
SJ
2013/07/25
Email: sj@toright.com
Blog: http://blog.toright.com
回顧 HTTP 1.1 的設計理念
Architectural Styles and the Design of Network-based Software Architectures (by Roy Thomas
Fielding)
CHAPTER 5. Representational State Transfer (REST)
HTTP Features
● HTTP 1.1 設計 Cache 的目的在降低
Request 與 Full Response
● 以下兩個主要的設計理念
○ Expiration
○ Validation
● 實作上透過 Header 讓 Server 與 Client 可以
自由定義 Cache 的方式
HTTP 1.0 與 HTTP 1.1 Caching Difference
HTTP 1.0 Reponse Cache Header
○ Expires
○ Pragma
HTTP 1.1 Reponse Cache Header
○ Cache-Control
介紹 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
● 可以混搭
如何檢查 Cache 是否有效?
● 時間導向 (秒為單位)
Last-Modified / If-Modified-Since
● 檔案內容導向 (Hash)
ETag / If-None-Match
Cache-Control: no-store
Cache-Control: no-cache
Cache-Control: max-age
Cache-Control: private
Cache-Control: public
Cache-Control: must-revalidate
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)
Thanks!
The End
Email: sj@toright.com
Blog: http://blog.toright.com

More Related Content

What's hot

20081128 http caching_in_php
20081128 http caching_in_php20081128 http caching_in_php
20081128 http caching_in_phpHunter Wu
 
统一接入的架构思考
统一接入的架构思考统一接入的架构思考
统一接入的架构思考yang bingwu
 
How svn work_and_how_to_use
How svn work_and_how_to_useHow svn work_and_how_to_use
How svn work_and_how_to_useBin Feng
 
JobTracker Memory Leak Solution
JobTracker  Memory Leak SolutionJobTracker  Memory Leak Solution
JobTracker Memory Leak Solutionjiang yu
 
前端性能测试
前端性能测试前端性能测试
前端性能测试tbmallf2e
 
Track2 -刘继伟--openstack in gamewave
Track2 -刘继伟--openstack in gamewaveTrack2 -刘继伟--openstack in gamewave
Track2 -刘继伟--openstack in gamewaveOpenCity Community
 
使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡cachowu
 
基于OpenResty的百万级长连接推送
基于OpenResty的百万级长连接推送基于OpenResty的百万级长连接推送
基于OpenResty的百万级长连接推送OpenRestyCon
 
Build scalable microblog qcon beijing 2010
Build scalable microblog qcon beijing 2010Build scalable microblog qcon beijing 2010
Build scalable microblog qcon beijing 2010Tim Y
 
大数据时代feed架构 (ArchSummit Beijing 2014)
大数据时代feed架构 (ArchSummit Beijing 2014)大数据时代feed架构 (ArchSummit Beijing 2014)
大数据时代feed架构 (ArchSummit Beijing 2014)Tim Y
 
NODEjs Lesson1
NODEjs Lesson1NODEjs Lesson1
NODEjs Lesson13dmodeldiy
 

What's hot (11)

20081128 http caching_in_php
20081128 http caching_in_php20081128 http caching_in_php
20081128 http caching_in_php
 
统一接入的架构思考
统一接入的架构思考统一接入的架构思考
统一接入的架构思考
 
How svn work_and_how_to_use
How svn work_and_how_to_useHow svn work_and_how_to_use
How svn work_and_how_to_use
 
JobTracker Memory Leak Solution
JobTracker  Memory Leak SolutionJobTracker  Memory Leak Solution
JobTracker Memory Leak Solution
 
前端性能测试
前端性能测试前端性能测试
前端性能测试
 
Track2 -刘继伟--openstack in gamewave
Track2 -刘继伟--openstack in gamewaveTrack2 -刘继伟--openstack in gamewave
Track2 -刘继伟--openstack in gamewave
 
使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡
 
基于OpenResty的百万级长连接推送
基于OpenResty的百万级长连接推送基于OpenResty的百万级长连接推送
基于OpenResty的百万级长连接推送
 
Build scalable microblog qcon beijing 2010
Build scalable microblog qcon beijing 2010Build scalable microblog qcon beijing 2010
Build scalable microblog qcon beijing 2010
 
大数据时代feed架构 (ArchSummit Beijing 2014)
大数据时代feed架构 (ArchSummit Beijing 2014)大数据时代feed架构 (ArchSummit Beijing 2014)
大数据时代feed架构 (ArchSummit Beijing 2014)
 
NODEjs Lesson1
NODEjs Lesson1NODEjs Lesson1
NODEjs Lesson1
 

Viewers also liked

小猴子也會的 Ubuntu Desktop 14.04 安裝教學
小猴子也會的 Ubuntu Desktop 14.04 安裝教學小猴子也會的 Ubuntu Desktop 14.04 安裝教學
小猴子也會的 Ubuntu Desktop 14.04 安裝教學家弘 周
 
SEO 武林天下
SEO 武林天下SEO 武林天下
SEO 武林天下家弘 周
 
敏捷開花那些小事
敏捷開花那些小事敏捷開花那些小事
敏捷開花那些小事家弘 周
 
The Clean Coder - 預估與壓力 (書摘)
The Clean Coder - 預估與壓力 (書摘)The Clean Coder - 預估與壓力 (書摘)
The Clean Coder - 預估與壓力 (書摘)家弘 周
 
Http Headers 與 Cache 機制(2016)
Http Headers 與 Cache 機制(2016)Http Headers 與 Cache 機制(2016)
Http Headers 與 Cache 機制(2016)振揚 陳
 
軟體品質與持續整合
軟體品質與持續整合軟體品質與持續整合
軟體品質與持續整合家弘 周
 
MOPCON 2015 - 軟體、測試、程式設計家
MOPCON 2015 - 軟體、測試、程式設計家MOPCON 2015 - 軟體、測試、程式設計家
MOPCON 2015 - 軟體、測試、程式設計家家弘 周
 
REST to RESTful Web Service
REST to RESTful Web ServiceREST to RESTful Web Service
REST to RESTful Web Service家弘 周
 

Viewers also liked (8)

小猴子也會的 Ubuntu Desktop 14.04 安裝教學
小猴子也會的 Ubuntu Desktop 14.04 安裝教學小猴子也會的 Ubuntu Desktop 14.04 安裝教學
小猴子也會的 Ubuntu Desktop 14.04 安裝教學
 
SEO 武林天下
SEO 武林天下SEO 武林天下
SEO 武林天下
 
敏捷開花那些小事
敏捷開花那些小事敏捷開花那些小事
敏捷開花那些小事
 
The Clean Coder - 預估與壓力 (書摘)
The Clean Coder - 預估與壓力 (書摘)The Clean Coder - 預估與壓力 (書摘)
The Clean Coder - 預估與壓力 (書摘)
 
Http Headers 與 Cache 機制(2016)
Http Headers 與 Cache 機制(2016)Http Headers 與 Cache 機制(2016)
Http Headers 與 Cache 機制(2016)
 
軟體品質與持續整合
軟體品質與持續整合軟體品質與持續整合
軟體品質與持續整合
 
MOPCON 2015 - 軟體、測試、程式設計家
MOPCON 2015 - 軟體、測試、程式設計家MOPCON 2015 - 軟體、測試、程式設計家
MOPCON 2015 - 軟體、測試、程式設計家
 
REST to RESTful Web Service
REST to RESTful Web ServiceREST to RESTful Web Service
REST to RESTful Web Service
 

Similar to Caching in HTTP

20111018 zhouchen share
20111018 zhouchen share20111018 zhouchen share
20111018 zhouchen sharezcbug
 
Apache trafficserver
Apache trafficserverApache trafficserver
Apache trafficserverDin Dindin
 
Http cache 的優化
Http cache 的優化Http cache 的優化
Http cache 的優化振揚 陳
 
Share http2
Share   http2Share   http2
Share http2garyxu17
 
Golang 高性能实战
Golang 高性能实战Golang 高性能实战
Golang 高性能实战rfyiamcool
 
前端性能优化&测试
前端性能优化&测试前端性能优化&测试
前端性能优化&测试tbmallf2e
 
前端调试工具,编码相关,性能相关
前端调试工具,编码相关,性能相关前端调试工具,编码相关,性能相关
前端调试工具,编码相关,性能相关jay li
 
Traffic server overview
Traffic server overviewTraffic server overview
Traffic server overviewqianshi
 
初學者都該了解的 HTTP 通訊協定基礎
初學者都該了解的 HTTP 通訊協定基礎初學者都該了解的 HTTP 通訊協定基礎
初學者都該了解的 HTTP 通訊協定基礎Will Huang
 

Similar to Caching in HTTP (10)

20111018 zhouchen share
20111018 zhouchen share20111018 zhouchen share
20111018 zhouchen share
 
Apache trafficserver
Apache trafficserverApache trafficserver
Apache trafficserver
 
Http cache 的優化
Http cache 的優化Http cache 的優化
Http cache 的優化
 
Share http2
Share   http2Share   http2
Share http2
 
Golang 高性能实战
Golang 高性能实战Golang 高性能实战
Golang 高性能实战
 
前端性能优化&测试
前端性能优化&测试前端性能优化&测试
前端性能优化&测试
 
Html5
Html5Html5
Html5
 
前端调试工具,编码相关,性能相关
前端调试工具,编码相关,性能相关前端调试工具,编码相关,性能相关
前端调试工具,编码相关,性能相关
 
Traffic server overview
Traffic server overviewTraffic server overview
Traffic server overview
 
初學者都該了解的 HTTP 通訊協定基礎
初學者都該了解的 HTTP 通訊協定基礎初學者都該了解的 HTTP 通訊協定基礎
初學者都該了解的 HTTP 通訊協定基礎
 

More from 家弘 周

2020 MLaaS 產業介紹.pdf
2020 MLaaS 產業介紹.pdf2020 MLaaS 產業介紹.pdf
2020 MLaaS 產業介紹.pdf家弘 周
 
用 Keras 玩 Machine Learning
用 Keras 玩 Machine Learning用 Keras 玩 Machine Learning
用 Keras 玩 Machine Learning家弘 周
 
Linux Container Introduction
Linux Container IntroductionLinux Container Introduction
Linux Container Introduction家弘 周
 
Cloud Foundry Introduction
Cloud Foundry IntroductionCloud Foundry Introduction
Cloud Foundry Introduction家弘 周
 
區塊鏈共識機制與 EOS
區塊鏈共識機制與 EOS區塊鏈共識機制與 EOS
區塊鏈共識機制與 EOS家弘 周
 
簡單線性回歸 & K-Means (Machine learning)
簡單線性回歸 & K-Means (Machine learning)簡單線性回歸 & K-Means (Machine learning)
簡單線性回歸 & K-Means (Machine learning)家弘 周
 
WordPress Blog SEO 兩三事
WordPress Blog SEO 兩三事WordPress Blog SEO 兩三事
WordPress Blog SEO 兩三事家弘 周
 

More from 家弘 周 (7)

2020 MLaaS 產業介紹.pdf
2020 MLaaS 產業介紹.pdf2020 MLaaS 產業介紹.pdf
2020 MLaaS 產業介紹.pdf
 
用 Keras 玩 Machine Learning
用 Keras 玩 Machine Learning用 Keras 玩 Machine Learning
用 Keras 玩 Machine Learning
 
Linux Container Introduction
Linux Container IntroductionLinux Container Introduction
Linux Container Introduction
 
Cloud Foundry Introduction
Cloud Foundry IntroductionCloud Foundry Introduction
Cloud Foundry Introduction
 
區塊鏈共識機制與 EOS
區塊鏈共識機制與 EOS區塊鏈共識機制與 EOS
區塊鏈共識機制與 EOS
 
簡單線性回歸 & K-Means (Machine learning)
簡單線性回歸 & K-Means (Machine learning)簡單線性回歸 & K-Means (Machine learning)
簡單線性回歸 & K-Means (Machine learning)
 
WordPress Blog SEO 兩三事
WordPress Blog SEO 兩三事WordPress Blog SEO 兩三事
WordPress Blog SEO 兩三事
 

Caching in HTTP