SlideShare a Scribd company logo
HTTP Caching Basics
Agenda
HTTP Basics
Cache-Related HTTP Headers
Expiration
Revalidation
Variation
HTTP Basics
HTTP Basics - Browser and origin server
Browser
Origin
Server
HTTP Basics - Resource
Browser
Origin
Server
Resource
/index.html
HTTP Basics - Request and response
Browser
Origin
Server
Resource
/index.html
Request
Response
HTTP Basics - Representation
Browser
Origin
Server
Resource
/index.html
Request
Response
Representation
Cached Representation
HTTP Basics - Method and status code
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Representation
HTTP Method
HTTP Status Code
HTTP Basics - Request and response headers
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Accept: text/html ...
Accept-Encoding: gzip, deflate, sdch, br
User-Agent: Mozilla/5.0 …
Cookie: PHPSESSID=12b239d7825bd8d21d5e60df56cbc3a5;
Response
HTTP/1.1 200 OK
Content-Type: text/html
Content-Encoding: gzip
Date: Fri, 16 Sep 2016 12:13:45 GMT
Representation
Request header
Response header
HTTP Basics - Intermediaries
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Representation
Intermediary
Representation
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Resource
/index.html
Quiz: What kind of intermediaries can
you think of?
HTTP Basics - Intermediate caches
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Representation
Intermediate
Cache
(Akamai,
Varnish)
Representation
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Resource
/index.html
Cached
Representations
Cache-Related HTTP Headers
Quiz: Which cache-related
HTTP headers do you know?
Cache-related HTTP headers
Expiration
Cache-Control
Expires
Age
Pragma
Variation
Vary
Revalidation
ETag
Last-Modified
If-Modified-Since
If-None-Match
Quiz: Which are request and which are response
headers?
Header Request Response
Cache-Control
Expires
Age
Pragma
ETag
Last-Modified
If-Modified-Since
If-None-Match
Vary
Cache-related HTTP headers in requests and
responses
Header Request Response
Cache-Control x x
Expires x
Age x
Pragma x x
ETag x
Last-Modified x
If-Modified-Since x
If-None-Match x
Vary x
Expiration
Expiration - Absolute vs. relative expiration date
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Expires: Fri, 16 Sep 2016 13:00:00 GMT
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: max-age=2700
Cached
Representation
Cached
Representation
Quiz: Which Cache-Control directives
do you know?
Expiration - Cache-Control directives
Directives Request Response
no-cache x x
no-store x x
max-age x x
s-maxage x
max-stale x
min-fresh x
no-transform x x
only-if-cached x
public x
private x
must-revalidate x
proxy-revalidate x
Expiration - Enforce revalidation with origin server
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: max-age=2700, must-revalidate
Cached
Representation
RepresentationNever use stale representation
(even if origin server is down)
Expiration - No-cache shortcut
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: max-age=0, must-revalidate
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: no-cache
=
Cached
Representation
Cached
Representation
Expiration - No-cache vs. no-store
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: no-cache
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: no-store
Cached
Representation
Cached
Representation
Expiration - Age specifies how long representation is
cached already
Response
HTTP/1.1 200 OK
Cache-Control: max-age=2700
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Cache-Control: max-age=2700
Age: 0
Intermediate
Cache
(Akamai,
Varnish)
Request
GET /index.html HTTP/1.1
Resource
/index.html
1st Request
2nd Request 15 Minutes Later Different Browser
Browser
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Cache-Control: max-age=2700
Age: 900
Intermediate
Cache
(Akamai,
Varnish)Resource
/index.html
Cached
Representation
Cached
Representation
Revalidation
Revalidation - Based on what?
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: max-age=2700, must-revalidate
Cached
Representation
Representation
Revalidation based on what?
Revalidation - Weak vs. strong cache validator
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: max-age=2700, must-revalidate
Last-Modified: Fri, 15 Sep 2016 12:00:00 GMT
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: max-age=2700, must-revalidate
ETag: "3e86-410-3596fbbc"
Cached
Representation
Cached
Representation
Revalidation - Revalidation based on Last-Modified
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
If-Modified-Since: Fri, 15 Sep 2016 12:00:00 GMT
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 13:00:00 GMT
Cache-Control: max-age=2700, must-revalidate
Last-Modified: Fri, 16 Sep 2016 13:00:00 GMT
Browser
Origin
Server
Resource
/index.html
Response
HTTP/1.1 304 Not Modified
Date: Fri, 16 Sep 2016 13:00:00 GMT
Cache-Control: max-age=2700, must-revalidate
Last-Modified: Fri, 15 Sep 2016 12:00:00 GMT
Cached
Representation
Cached
Representation
OR
Revalidation - Revalidation based on ETag
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
If-None-Match: "3e86-410-3596fbbc"
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 13:00:00 GMT
Cache-Control: max-age=2700, must-revalidate
ETag: "6e35-240-2672fbbc"
Browser
Origin
Server
Resource
/index.html
Response
HTTP/1.1 304 Not Modified
Date: Fri, 16 Sep 2016 13:00:00 GMT
Cache-Control: max-age=2700, must-revalidate
ETag: "3e86-410-3596fbbc"
Cached
Representation
Cached
Representation
OR
Quiz: How does revalidation behave for
different Cache-Control setups?
Expiration - No-store means no revalidation possible
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: no-cache
Last-Modified: Fri, 15 Sep 2016 12:00:00 GMT
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Response
HTTP/1.1 200 OK
Date: Fri, 16 Sep 2016 12:15:00 GMT
Cache-Control: no-store
Last-Modified: Fri, 15 Sep 2016 12:00:00 GMT
Cached
Representation
Cached
Representation
Variation
Variation - Most common is Vary on Accept-Encoding
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
Response
HTTP/1.1 200 OK
Content-Encoding: gzip
Vary: Accept-Encoding
Representation
Means different zipped and unzipped
variants of representation are possible.
Response
HTTP/1.1 200 OK
Vary: Accept-Encoding
Variation - Used to control behavior of intermediate
caches
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
Response
HTTP/1.1 200 OK
Vary: Accept-Encoding
Representation
Intermediate
Cache
(Akamai,
Varnish)
Representation
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
Resource
/index.html
Cached
Representations
Accept-Encoding: gzip Empty Accept-Encoding
Response
HTTP/1.1 200 OK
Vary: Accept-Encoding,
User-Agent
Variation - Also used in combination with User-Agent
to deliver device type specific content
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
User-Agent: Chrome …
Response
HTTP/1.1 200 OK
Vary: Accept-Encoding,
User-Agent
Representation
Intermediate
Cache
(Akamai,
Varnish)
Representation
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
User-Agent: Chrome …
Resource
/index.html
Cached
Representations
Accept-Encoding: gzip
User-Agent: Chrome …
Accept-Encoding: gzip
User-Agent: Edge …
Quiz: What is the problem with that
setup?
Combinations are endless and
hit rate will be really low
Response
HTTP/1.1 200 OK
Vary: Accept-Encoding,
User-Agent
Variation - Wrong usage of Vary header can lead to
low hit rates
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
User-Agent: Chrome …
Response
HTTP/1.1 200 OK
Vary: Accept-Encoding,
User-Agent
Representation
Intermediate
Cache
(Akamai,
Varnish)
Representation
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
User-Agent: Chrome …
Resource
/index.html
Cached
Representations
Accept-Encoding: gzip
User-Agent: Chrome …
Accept-Encoding: gzip
User-Agent: Edge …
Combinations are endless and
hit rate will be really low
Response
HTTP/1.1 200 OK
Vary: Accept-Encoding,
User-Agent
Variation - Don’t do it like that
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
User-Agent: Chrome …
Response
HTTP/1.1 200 OK
Vary: Accept-Encoding,
User-Agent
Representation
Intermediate
Cache
(Akamai,
Varnish)
Representation
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
User-Agent: Chrome …
Resource
/index.html
Cached
Representations
Accept-Encoding: gzip
User-Agent: Chrome …
Accept-Encoding: gzip
User-Agent: Edge …
Response
HTTP/1.1 200 OK
Vary: Accept-Encoding,
X-Device
Variation - Create generic header to improve hit rate
and return private in Cache-Control to avoid caching
Browser
Origin
Server
Resource
/index.html
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
User-Agent: Chrome ...
Response
HTTP/1.1 200 OK
Cache-Control: private
Representation
Intermediate
Cache
(Akamai,
Varnish)
Representation
Request
GET /index.html HTTP/1.1
Accept-Encoding: gzip
X-Device: Mobile
Resource
/index.html
Cached
Representations
Accept-Encoding: gzip
X-Device: Mobile
Accept-Encoding: gzip
X-Device: Desktop
Conclusion
Conclusion
Use Cache-Control header in general to control caching behaviour
Implement ETag and/or Last-Modified to allow for revalidation
Do not use User-Agent in Vary header and rather extract required attributes and
work with X-... headers
Questions?

More Related Content

What's hot

HBase: How to get MTTR below 1 minute
HBase: How to get MTTR below 1 minuteHBase: How to get MTTR below 1 minute
HBase: How to get MTTR below 1 minute
Hortonworks
 
Distributed Counters in Cassandra (Cassandra Summit 2010)
Distributed Counters in Cassandra (Cassandra Summit 2010)Distributed Counters in Cassandra (Cassandra Summit 2010)
Distributed Counters in Cassandra (Cassandra Summit 2010)
kakugawa
 
Nginx
NginxNginx
Stream processing using Kafka
Stream processing using KafkaStream processing using Kafka
Stream processing using Kafka
Knoldus Inc.
 
Kafka 101
Kafka 101Kafka 101
Kafka 101
Aparna Pillai
 
Where is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in FlinkWhere is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in Flink
Flink Forward
 
Http request&response by Vignesh 15 MAR 2014
Http request&response by Vignesh 15 MAR 2014Http request&response by Vignesh 15 MAR 2014
Http request&response by Vignesh 15 MAR 2014
Navaneethan Naveen
 
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
Open Source Consulting
 
Anypoint mq queues and exchanges
Anypoint mq queues and exchangesAnypoint mq queues and exchanges
Anypoint mq queues and exchanges
Son Nguyen
 
Auto Update(AUT) - HCL Notes
Auto Update(AUT) -  HCL NotesAuto Update(AUT) -  HCL Notes
Auto Update(AUT) - HCL Notes
Ranjit Rai
 
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA BroadcastNGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX, Inc.
 
Introduction to Haproxy
Introduction to HaproxyIntroduction to Haproxy
Introduction to Haproxy
Shaopeng He
 
Terraform modules and (some of) best practices
Terraform modules and (some of) best practicesTerraform modules and (some of) best practices
Terraform modules and (some of) best practices
Anton Babenko
 
Inverted page tables basic
Inverted page tables basicInverted page tables basic
Inverted page tables basic
Sanoj Kumar
 
Introduction to Nginx
Introduction to NginxIntroduction to Nginx
Introduction to Nginx
Knoldus Inc.
 
Caching Strategies
Caching StrategiesCaching Strategies
Caching Strategies
Michal Špaček
 
Distributed operating system amoeba case study
Distributed operating system  amoeba case studyDistributed operating system  amoeba case study
Distributed operating system amoeba case study
RamuAryan
 
Nginx Essential
Nginx EssentialNginx Essential
Nginx Essential
Gong Haibing
 
Http request smuggling
Http request smugglingHttp request smuggling
Http request smuggling
n|u - The Open Security Community
 
Fluentd and Distributed Logging at Kubecon
Fluentd and Distributed Logging at KubeconFluentd and Distributed Logging at Kubecon
Fluentd and Distributed Logging at Kubecon
N Masahiro
 

What's hot (20)

HBase: How to get MTTR below 1 minute
HBase: How to get MTTR below 1 minuteHBase: How to get MTTR below 1 minute
HBase: How to get MTTR below 1 minute
 
Distributed Counters in Cassandra (Cassandra Summit 2010)
Distributed Counters in Cassandra (Cassandra Summit 2010)Distributed Counters in Cassandra (Cassandra Summit 2010)
Distributed Counters in Cassandra (Cassandra Summit 2010)
 
Nginx
NginxNginx
Nginx
 
Stream processing using Kafka
Stream processing using KafkaStream processing using Kafka
Stream processing using Kafka
 
Kafka 101
Kafka 101Kafka 101
Kafka 101
 
Where is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in FlinkWhere is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in Flink
 
Http request&response by Vignesh 15 MAR 2014
Http request&response by Vignesh 15 MAR 2014Http request&response by Vignesh 15 MAR 2014
Http request&response by Vignesh 15 MAR 2014
 
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
 
Anypoint mq queues and exchanges
Anypoint mq queues and exchangesAnypoint mq queues and exchanges
Anypoint mq queues and exchanges
 
Auto Update(AUT) - HCL Notes
Auto Update(AUT) -  HCL NotesAuto Update(AUT) -  HCL Notes
Auto Update(AUT) - HCL Notes
 
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA BroadcastNGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA Broadcast
 
Introduction to Haproxy
Introduction to HaproxyIntroduction to Haproxy
Introduction to Haproxy
 
Terraform modules and (some of) best practices
Terraform modules and (some of) best practicesTerraform modules and (some of) best practices
Terraform modules and (some of) best practices
 
Inverted page tables basic
Inverted page tables basicInverted page tables basic
Inverted page tables basic
 
Introduction to Nginx
Introduction to NginxIntroduction to Nginx
Introduction to Nginx
 
Caching Strategies
Caching StrategiesCaching Strategies
Caching Strategies
 
Distributed operating system amoeba case study
Distributed operating system  amoeba case studyDistributed operating system  amoeba case study
Distributed operating system amoeba case study
 
Nginx Essential
Nginx EssentialNginx Essential
Nginx Essential
 
Http request smuggling
Http request smugglingHttp request smuggling
Http request smuggling
 
Fluentd and Distributed Logging at Kubecon
Fluentd and Distributed Logging at KubeconFluentd and Distributed Logging at Kubecon
Fluentd and Distributed Logging at Kubecon
 

Viewers also liked

Advanced HTTP Caching
Advanced HTTP CachingAdvanced HTTP Caching
Advanced HTTP Caching
Martin Breest
 
Notesmaster training manual for content developers
Notesmaster training manual for content developersNotesmaster training manual for content developers
Notesmaster training manual for content developers
dean dundas
 
Production logs
Production logsProduction logs
Production logs
AdamPatersonMedia
 
Getting Started with STEAM
Getting Started with STEAMGetting Started with STEAM
Getting Started with STEAM
Fayetteville Free Library
 
Open Education for Digped PEI
Open Education for Digped PEIOpen Education for Digped PEI
Open Education for Digped PEI
Robin DeRosa
 
Application of Derivative 7
Application of Derivative 7Application of Derivative 7
Application of Derivative 7
Lakshmikanta Satapathy
 
Bridging worlds connecting minds calongne
Bridging worlds connecting minds calongneBridging worlds connecting minds calongne
Bridging worlds connecting minds calongne
Cynthia Calongne
 
SiTraRed: "Como consultar el estado de las tarjetas"
SiTraRed: "Como consultar el estado de las tarjetas" SiTraRed: "Como consultar el estado de las tarjetas"
SiTraRed: "Como consultar el estado de las tarjetas"
Lic. Cecilia B. Vera
 
PEB Steel - Chinese brochure - 2016
PEB Steel - Chinese brochure - 2016PEB Steel - Chinese brochure - 2016
PEB Steel - Chinese brochure - 2016
PEB Steel Buildings
 
PEB STEEL BUILDINGS
PEB STEEL BUILDINGSPEB STEEL BUILDINGS
PEB STEEL BUILDINGS
PEB Steel Buildings
 
Wayne lsl slideshare
Wayne lsl slideshareWayne lsl slideshare
Wayne lsl slideshare
Connie Hamilton Ed.S.
 
Serious Play Conference: Edtech Evangelist: Converting the Unbelievers
Serious Play Conference: Edtech Evangelist: Converting the UnbelieversSerious Play Conference: Edtech Evangelist: Converting the Unbelievers
Serious Play Conference: Edtech Evangelist: Converting the Unbelievers
David W. Deeds
 
Using Stories for Learning
Using Stories for Learning Using Stories for Learning
Using Stories for Learning
Aurion Learning
 
PEB Steel Building, Projects of Pre Engineered Steel Building, Metal structur...
PEB Steel Building, Projects of Pre Engineered Steel Building, Metal structur...PEB Steel Building, Projects of Pre Engineered Steel Building, Metal structur...
PEB Steel Building, Projects of Pre Engineered Steel Building, Metal structur...
Duy Dang
 
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
Cliff Seal
 
Simulation and Modeling
Simulation and ModelingSimulation and Modeling
Simulation and Modeling
anhdbh
 
Unique range of Access Hardware - available from Albert Jagger
Unique range of Access Hardware - available from Albert JaggerUnique range of Access Hardware - available from Albert Jagger
Unique range of Access Hardware - available from Albert Jagger
Albert Jagger
 

Viewers also liked (17)

Advanced HTTP Caching
Advanced HTTP CachingAdvanced HTTP Caching
Advanced HTTP Caching
 
Notesmaster training manual for content developers
Notesmaster training manual for content developersNotesmaster training manual for content developers
Notesmaster training manual for content developers
 
Production logs
Production logsProduction logs
Production logs
 
Getting Started with STEAM
Getting Started with STEAMGetting Started with STEAM
Getting Started with STEAM
 
Open Education for Digped PEI
Open Education for Digped PEIOpen Education for Digped PEI
Open Education for Digped PEI
 
Application of Derivative 7
Application of Derivative 7Application of Derivative 7
Application of Derivative 7
 
Bridging worlds connecting minds calongne
Bridging worlds connecting minds calongneBridging worlds connecting minds calongne
Bridging worlds connecting minds calongne
 
SiTraRed: "Como consultar el estado de las tarjetas"
SiTraRed: "Como consultar el estado de las tarjetas" SiTraRed: "Como consultar el estado de las tarjetas"
SiTraRed: "Como consultar el estado de las tarjetas"
 
PEB Steel - Chinese brochure - 2016
PEB Steel - Chinese brochure - 2016PEB Steel - Chinese brochure - 2016
PEB Steel - Chinese brochure - 2016
 
PEB STEEL BUILDINGS
PEB STEEL BUILDINGSPEB STEEL BUILDINGS
PEB STEEL BUILDINGS
 
Wayne lsl slideshare
Wayne lsl slideshareWayne lsl slideshare
Wayne lsl slideshare
 
Serious Play Conference: Edtech Evangelist: Converting the Unbelievers
Serious Play Conference: Edtech Evangelist: Converting the UnbelieversSerious Play Conference: Edtech Evangelist: Converting the Unbelievers
Serious Play Conference: Edtech Evangelist: Converting the Unbelievers
 
Using Stories for Learning
Using Stories for Learning Using Stories for Learning
Using Stories for Learning
 
PEB Steel Building, Projects of Pre Engineered Steel Building, Metal structur...
PEB Steel Building, Projects of Pre Engineered Steel Building, Metal structur...PEB Steel Building, Projects of Pre Engineered Steel Building, Metal structur...
PEB Steel Building, Projects of Pre Engineered Steel Building, Metal structur...
 
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
Introducing WordPress Multitenancy (Wordcamp Vegas/Orlando 2015/WPCampus)
 
Simulation and Modeling
Simulation and ModelingSimulation and Modeling
Simulation and Modeling
 
Unique range of Access Hardware - available from Albert Jagger
Unique range of Access Hardware - available from Albert JaggerUnique range of Access Hardware - available from Albert Jagger
Unique range of Access Hardware - available from Albert Jagger
 

Similar to Http caching basics

Caching on the Edge
Caching on the EdgeCaching on the Edge
Caching on the Edge
Fabien Potencier
 
HTTP/2, SPDY e Otimizações Web - Front In Maceió 2014 - Sérgio Lopes
HTTP/2, SPDY e Otimizações Web - Front In Maceió 2014 - Sérgio LopesHTTP/2, SPDY e Otimizações Web - Front In Maceió 2014 - Sérgio Lopes
HTTP/2, SPDY e Otimizações Web - Front In Maceió 2014 - Sérgio Lopes
Caelum
 
Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018
Thijs Feryn
 
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
Alessandro Nadalin
 
Caching the Uncacheable
Caching the UncacheableCaching the Uncacheable
Caching the Uncacheable
danrot
 
HTTP colon slash slash: the end of the road?
HTTP colon slash slash: the end of the road?HTTP colon slash slash: the end of the road?
HTTP colon slash slash: the end of the road?
Alessandro Nadalin
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web Application
Martins Sipenko
 
Developing cacheable PHP applications - Confoo 2018
Developing cacheable PHP applications - Confoo 2018Developing cacheable PHP applications - Confoo 2018
Developing cacheable PHP applications - Confoo 2018
Thijs Feryn
 
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Codemotion
 
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Thijs Feryn
 
HTTP fundamentals for developers
HTTP fundamentals for developersHTTP fundamentals for developers
HTTP fundamentals for developers
Mario Cardinal
 
REST in peace @ IPC 2012 in Mainz
REST in peace @ IPC 2012 in MainzREST in peace @ IPC 2012 in Mainz
REST in peace @ IPC 2012 in Mainz
Alessandro Nadalin
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)
Данил Иванов
 
Web Site Optimization
Web Site OptimizationWeb Site Optimization
Web Site Optimization
Sunil Patil
 
Web site optimization
Web site optimizationWeb site optimization
Web site optimization
Sunil Patil
 
Under the Covers with the Web
Under the Covers with the WebUnder the Covers with the Web
Under the Covers with the Web
Trevor Lohrbeer
 
HTTP and Your Angry Dog
HTTP and Your Angry DogHTTP and Your Angry Dog
HTTP and Your Angry Dog
Ross Tuck
 
Web performance - Analysing Heart.co.uk
Web performance - Analysing Heart.co.ukWeb performance - Analysing Heart.co.uk
Web performance - Analysing Heart.co.uk
gareth53
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable Stack
Bruno Paiuca
 
5 steps to faster web sites & HTML5 games - updated for DDDscot
5 steps to faster web sites & HTML5 games - updated for DDDscot5 steps to faster web sites & HTML5 games - updated for DDDscot
5 steps to faster web sites & HTML5 games - updated for DDDscot
Michael Ewins
 

Similar to Http caching basics (20)

Caching on the Edge
Caching on the EdgeCaching on the Edge
Caching on the Edge
 
HTTP/2, SPDY e Otimizações Web - Front In Maceió 2014 - Sérgio Lopes
HTTP/2, SPDY e Otimizações Web - Front In Maceió 2014 - Sérgio LopesHTTP/2, SPDY e Otimizações Web - Front In Maceió 2014 - Sérgio Lopes
HTTP/2, SPDY e Otimizações Web - Front In Maceió 2014 - Sérgio Lopes
 
Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018
 
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
 
Caching the Uncacheable
Caching the UncacheableCaching the Uncacheable
Caching the Uncacheable
 
HTTP colon slash slash: the end of the road?
HTTP colon slash slash: the end of the road?HTTP colon slash slash: the end of the road?
HTTP colon slash slash: the end of the road?
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web Application
 
Developing cacheable PHP applications - Confoo 2018
Developing cacheable PHP applications - Confoo 2018Developing cacheable PHP applications - Confoo 2018
Developing cacheable PHP applications - Confoo 2018
 
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
 
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
 
HTTP fundamentals for developers
HTTP fundamentals for developersHTTP fundamentals for developers
HTTP fundamentals for developers
 
REST in peace @ IPC 2012 in Mainz
REST in peace @ IPC 2012 in MainzREST in peace @ IPC 2012 in Mainz
REST in peace @ IPC 2012 in Mainz
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)
 
Web Site Optimization
Web Site OptimizationWeb Site Optimization
Web Site Optimization
 
Web site optimization
Web site optimizationWeb site optimization
Web site optimization
 
Under the Covers with the Web
Under the Covers with the WebUnder the Covers with the Web
Under the Covers with the Web
 
HTTP and Your Angry Dog
HTTP and Your Angry DogHTTP and Your Angry Dog
HTTP and Your Angry Dog
 
Web performance - Analysing Heart.co.uk
Web performance - Analysing Heart.co.ukWeb performance - Analysing Heart.co.uk
Web performance - Analysing Heart.co.uk
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable Stack
 
5 steps to faster web sites & HTML5 games - updated for DDDscot
5 steps to faster web sites & HTML5 games - updated for DDDscot5 steps to faster web sites & HTML5 games - updated for DDDscot
5 steps to faster web sites & HTML5 games - updated for DDDscot
 

Recently uploaded

TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
HarisZaheer8
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 

Recently uploaded (20)

TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 

Http caching basics

  • 2. Agenda HTTP Basics Cache-Related HTTP Headers Expiration Revalidation Variation
  • 4. HTTP Basics - Browser and origin server Browser Origin Server
  • 5. HTTP Basics - Resource Browser Origin Server Resource /index.html
  • 6. HTTP Basics - Request and response Browser Origin Server Resource /index.html Request Response
  • 7. HTTP Basics - Representation Browser Origin Server Resource /index.html Request Response Representation Cached Representation
  • 8. HTTP Basics - Method and status code Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Representation HTTP Method HTTP Status Code
  • 9. HTTP Basics - Request and response headers Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Accept: text/html ... Accept-Encoding: gzip, deflate, sdch, br User-Agent: Mozilla/5.0 … Cookie: PHPSESSID=12b239d7825bd8d21d5e60df56cbc3a5; Response HTTP/1.1 200 OK Content-Type: text/html Content-Encoding: gzip Date: Fri, 16 Sep 2016 12:13:45 GMT Representation Request header Response header
  • 10. HTTP Basics - Intermediaries Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Representation Intermediary Representation Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Resource /index.html
  • 11. Quiz: What kind of intermediaries can you think of?
  • 12. HTTP Basics - Intermediate caches Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Representation Intermediate Cache (Akamai, Varnish) Representation Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Resource /index.html Cached Representations
  • 14. Quiz: Which cache-related HTTP headers do you know?
  • 16. Quiz: Which are request and which are response headers? Header Request Response Cache-Control Expires Age Pragma ETag Last-Modified If-Modified-Since If-None-Match Vary
  • 17. Cache-related HTTP headers in requests and responses Header Request Response Cache-Control x x Expires x Age x Pragma x x ETag x Last-Modified x If-Modified-Since x If-None-Match x Vary x
  • 19. Expiration - Absolute vs. relative expiration date Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Expires: Fri, 16 Sep 2016 13:00:00 GMT Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: max-age=2700 Cached Representation Cached Representation
  • 20. Quiz: Which Cache-Control directives do you know?
  • 21. Expiration - Cache-Control directives Directives Request Response no-cache x x no-store x x max-age x x s-maxage x max-stale x min-fresh x no-transform x x only-if-cached x public x private x must-revalidate x proxy-revalidate x
  • 22. Expiration - Enforce revalidation with origin server Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: max-age=2700, must-revalidate Cached Representation RepresentationNever use stale representation (even if origin server is down)
  • 23. Expiration - No-cache shortcut Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: max-age=0, must-revalidate Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: no-cache = Cached Representation Cached Representation
  • 24. Expiration - No-cache vs. no-store Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: no-cache Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: no-store Cached Representation Cached Representation
  • 25. Expiration - Age specifies how long representation is cached already Response HTTP/1.1 200 OK Cache-Control: max-age=2700 Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Cache-Control: max-age=2700 Age: 0 Intermediate Cache (Akamai, Varnish) Request GET /index.html HTTP/1.1 Resource /index.html 1st Request 2nd Request 15 Minutes Later Different Browser Browser Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Cache-Control: max-age=2700 Age: 900 Intermediate Cache (Akamai, Varnish)Resource /index.html Cached Representation Cached Representation
  • 27. Revalidation - Based on what? Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: max-age=2700, must-revalidate Cached Representation Representation Revalidation based on what?
  • 28. Revalidation - Weak vs. strong cache validator Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: max-age=2700, must-revalidate Last-Modified: Fri, 15 Sep 2016 12:00:00 GMT Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: max-age=2700, must-revalidate ETag: "3e86-410-3596fbbc" Cached Representation Cached Representation
  • 29. Revalidation - Revalidation based on Last-Modified Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 If-Modified-Since: Fri, 15 Sep 2016 12:00:00 GMT Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 13:00:00 GMT Cache-Control: max-age=2700, must-revalidate Last-Modified: Fri, 16 Sep 2016 13:00:00 GMT Browser Origin Server Resource /index.html Response HTTP/1.1 304 Not Modified Date: Fri, 16 Sep 2016 13:00:00 GMT Cache-Control: max-age=2700, must-revalidate Last-Modified: Fri, 15 Sep 2016 12:00:00 GMT Cached Representation Cached Representation OR
  • 30. Revalidation - Revalidation based on ETag Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 If-None-Match: "3e86-410-3596fbbc" Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 13:00:00 GMT Cache-Control: max-age=2700, must-revalidate ETag: "6e35-240-2672fbbc" Browser Origin Server Resource /index.html Response HTTP/1.1 304 Not Modified Date: Fri, 16 Sep 2016 13:00:00 GMT Cache-Control: max-age=2700, must-revalidate ETag: "3e86-410-3596fbbc" Cached Representation Cached Representation OR
  • 31. Quiz: How does revalidation behave for different Cache-Control setups?
  • 32. Expiration - No-store means no revalidation possible Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: no-cache Last-Modified: Fri, 15 Sep 2016 12:00:00 GMT Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Date: Fri, 16 Sep 2016 12:15:00 GMT Cache-Control: no-store Last-Modified: Fri, 15 Sep 2016 12:00:00 GMT Cached Representation Cached Representation
  • 34. Variation - Most common is Vary on Accept-Encoding Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Accept-Encoding: gzip Response HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding Representation Means different zipped and unzipped variants of representation are possible.
  • 35. Response HTTP/1.1 200 OK Vary: Accept-Encoding Variation - Used to control behavior of intermediate caches Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Accept-Encoding: gzip Response HTTP/1.1 200 OK Vary: Accept-Encoding Representation Intermediate Cache (Akamai, Varnish) Representation Request GET /index.html HTTP/1.1 Accept-Encoding: gzip Resource /index.html Cached Representations Accept-Encoding: gzip Empty Accept-Encoding
  • 36. Response HTTP/1.1 200 OK Vary: Accept-Encoding, User-Agent Variation - Also used in combination with User-Agent to deliver device type specific content Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Accept-Encoding: gzip User-Agent: Chrome … Response HTTP/1.1 200 OK Vary: Accept-Encoding, User-Agent Representation Intermediate Cache (Akamai, Varnish) Representation Request GET /index.html HTTP/1.1 Accept-Encoding: gzip User-Agent: Chrome … Resource /index.html Cached Representations Accept-Encoding: gzip User-Agent: Chrome … Accept-Encoding: gzip User-Agent: Edge …
  • 37. Quiz: What is the problem with that setup?
  • 38. Combinations are endless and hit rate will be really low Response HTTP/1.1 200 OK Vary: Accept-Encoding, User-Agent Variation - Wrong usage of Vary header can lead to low hit rates Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Accept-Encoding: gzip User-Agent: Chrome … Response HTTP/1.1 200 OK Vary: Accept-Encoding, User-Agent Representation Intermediate Cache (Akamai, Varnish) Representation Request GET /index.html HTTP/1.1 Accept-Encoding: gzip User-Agent: Chrome … Resource /index.html Cached Representations Accept-Encoding: gzip User-Agent: Chrome … Accept-Encoding: gzip User-Agent: Edge …
  • 39. Combinations are endless and hit rate will be really low Response HTTP/1.1 200 OK Vary: Accept-Encoding, User-Agent Variation - Don’t do it like that Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Accept-Encoding: gzip User-Agent: Chrome … Response HTTP/1.1 200 OK Vary: Accept-Encoding, User-Agent Representation Intermediate Cache (Akamai, Varnish) Representation Request GET /index.html HTTP/1.1 Accept-Encoding: gzip User-Agent: Chrome … Resource /index.html Cached Representations Accept-Encoding: gzip User-Agent: Chrome … Accept-Encoding: gzip User-Agent: Edge …
  • 40. Response HTTP/1.1 200 OK Vary: Accept-Encoding, X-Device Variation - Create generic header to improve hit rate and return private in Cache-Control to avoid caching Browser Origin Server Resource /index.html Request GET /index.html HTTP/1.1 Accept-Encoding: gzip User-Agent: Chrome ... Response HTTP/1.1 200 OK Cache-Control: private Representation Intermediate Cache (Akamai, Varnish) Representation Request GET /index.html HTTP/1.1 Accept-Encoding: gzip X-Device: Mobile Resource /index.html Cached Representations Accept-Encoding: gzip X-Device: Mobile Accept-Encoding: gzip X-Device: Desktop
  • 42. Conclusion Use Cache-Control header in general to control caching behaviour Implement ETag and/or Last-Modified to allow for revalidation Do not use User-Agent in Vary header and rather extract required attributes and work with X-... headers

Editor's Notes

  1. Representation - different based on request (mobile, desktop; uncompressed, compressed)
  2. Why? Caches, security, routing, ...
  3. Caching, Security, Routing, Logging Cross-cutting concerns
  4. Can cache representations Shorter response time Lower latency with edge caches (cache nodes near customer) Better scalability
  5. Why? What is the downside?
  6. -do not use without revalidation for subsequent requests -behaviour depends on browser -back-button might not qualify as subsequent request
  7. Why? What is the downside?