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?

Http caching basics

  • 1.
  • 2.
    Agenda HTTP Basics Cache-Related HTTPHeaders Expiration Revalidation Variation
  • 3.
  • 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 kindof 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
  • 13.
  • 14.
    Quiz: Which cache-related HTTPheaders do you know?
  • 15.
  • 16.
    Quiz: Which arerequest 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 headersin 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
  • 18.
  • 19.
    Expiration - Absolutevs. 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-Controldirectives do you know?
  • 21.
    Expiration - Cache-Controldirectives 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 - Enforcerevalidation 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-cacheshortcut 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-cachevs. 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 - Agespecifies 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
  • 26.
  • 27.
    Revalidation - Basedon 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 - Weakvs. 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 - Revalidationbased 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 - Revalidationbased 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 doesrevalidation behave for different Cache-Control setups?
  • 32.
    Expiration - No-storemeans 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
  • 33.
  • 34.
    Variation - Mostcommon 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 isthe problem with that setup?
  • 38.
    Combinations are endlessand 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 endlessand 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
  • 41.
  • 42.
    Conclusion Use Cache-Control headerin 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
  • 43.

Editor's Notes

  • #8 Representation - different based on request (mobile, desktop; uncompressed, compressed)
  • #11 Why? Caches, security, routing, ...
  • #12 Caching, Security, Routing, Logging Cross-cutting concerns
  • #13 Can cache representations Shorter response time Lower latency with edge caches (cache nodes near customer) Better scalability
  • #19 Why? What is the downside?
  • #24 -do not use without revalidation for subsequent requests -behaviour depends on browser -back-button might not qualify as subsequent request
  • #27 Why? What is the downside?