http cache @ pug rome 03-29-2011
DESCRIPTION
A short presentation about HTTP caching at the Rome PHP User Group.TRANSCRIPT
![Page 1: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/1.jpg)
HTTP cache
Alessandro Nadalin
March, 29th 2011
![Page 2: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/2.jpg)
The Webis
inconsistent
![Page 3: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/3.jpg)
get over it
![Page 4: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/4.jpg)
Why?
![Page 5: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/5.jpg)
Because it scales to billions of users
![Page 6: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/6.jpg)
Because it scales to billions of users
WWW data traffic won't be possible without being
inconsistent
![Page 7: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/7.jpg)
How does it scales?
![Page 8: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/8.jpg)
Cache
![Page 9: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/9.jpg)
What is caching?
![Page 10: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/10.jpg)
Storing data so that future requests for that data can be served faster
( general purpose )
![Page 11: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/11.jpg)
Process of storing copies of your most accessed resources near to a/some client/s
( the WWW )
![Page 12: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/12.jpg)
Caching is not saving a webpage, or a fragment of it, on the disk, to serve it to the next client
![Page 13: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/13.jpg)
Caching is not saving a webpage, or a fragment of it, on the disk, to serve it to the next client
This is a caching mechanism
![Page 14: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/14.jpg)
Disk-persisted or in-memory
![Page 15: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/15.jpg)
Can be distributed
![Page 16: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/16.jpg)
Can be distributed with a NoSQL database
![Page 17: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/17.jpg)
Cache implementation can be really funny
![Page 18: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/18.jpg)
Don't reinvent the wheel
![Page 19: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/19.jpg)
Goals
![Page 20: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/20.jpg)
Goals
evolve
![Page 21: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/21.jpg)
Goals
evolveloose coupling
![Page 22: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/22.jpg)
Goals
Work lessevolve
loose coupling
![Page 23: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/23.jpg)
Evolve Because you want your platform to extensible
![Page 24: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/24.jpg)
Evolve Because you want your platform to extensible
Loose coupling Because you want it to be easy to integrate with, evolve, plug and mantain
![Page 25: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/25.jpg)
Evolve Because you want your platform to extensible
Loose coupling Because you want it to be easy to integrate with, evolve, plug and mantain
Work less
Because every LoC is bug-prone and our man-day is a hard to scale cost
![Page 26: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/26.jpg)
enters our Hero #1
![Page 27: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/27.jpg)
![Page 28: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/28.jpg)
![Page 29: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/29.jpg)
enters our Hero #2
![Page 30: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/30.jpg)
![Page 31: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/31.jpg)
http://www.lullabot.com/articles/a-beginners-guide-to-caching-data
![Page 32: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/32.jpg)
Goals
Work lessevolve
loose coupling
![Page 33: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/33.jpg)
Goals
Work lessevolve
loose coupling
![Page 34: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/34.jpg)
everything is done for us!
:)
but....
![Page 35: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/35.jpg)
tmp files, cache tables, procedural crap...
mmmmh....
gotta be something better
![Page 36: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/36.jpg)
Frameworks
![Page 37: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/37.jpg)
![Page 38: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/38.jpg)
Cache is used for compiling routes, autoloading, ...
![Page 39: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/39.jpg)
Cache is used for compiling routes, autoloading, ...
...but also for storing the view
![Page 40: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/40.jpg)
Goals
Work lessevolve
loose coupling
![Page 41: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/41.jpg)
Goals
Work lessevolve
loose coupling
![Page 42: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/42.jpg)
at least because we use a framework
![Page 43: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/43.jpg)
but, probably
![Page 44: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/44.jpg)
PHP sucks
![Page 45: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/45.jpg)
Let's call a hero, from the East
![Page 46: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/46.jpg)
on Rails
![Page 47: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/47.jpg)
![Page 48: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/48.jpg)
Goals
Work lessevolve
loose coupling
![Page 49: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/49.jpg)
gosh :-(
![Page 50: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/50.jpg)
hey, what aboutthe latest
products?
![Page 51: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/51.jpg)
both Symfony2 andRuby's Rack embrace
![Page 52: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/52.jpg)
HTTP
![Page 53: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/53.jpg)
(here comes the nice part)
![Page 54: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/54.jpg)
Local
Shared/proxy
Shared/reverse proxy
![Page 55: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/55.jpg)
Local
Shared/proxy
Shared/reverse proxy
![Page 56: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/56.jpg)
![Page 57: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/57.jpg)
Local
Shared/proxy
Shared/reverse proxy
![Page 58: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/58.jpg)
![Page 59: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/59.jpg)
Local
Shared/proxy
Shared/reverse proxy
![Page 60: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/60.jpg)
![Page 61: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/61.jpg)
on the server side
![Page 62: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/62.jpg)
Proxy Reverse proxy
http://www.codeproject.com/KB/aspnet/ExploringCaching.aspx
![Page 63: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/63.jpg)
There is something cool about caching softwares.
![Page 64: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/64.jpg)
Free as free beer
![Page 65: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/65.jpg)
...but the server should take advantage of them
( the boring part were you need to write code )
![Page 66: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/66.jpg)
and here are a few ways to do so, using
![Page 67: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/67.jpg)
and here are a few ways to do so, using
expiration
![Page 68: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/68.jpg)
and here are a few ways to do so, using
expiration
validation
![Page 69: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/69.jpg)
and here are a few ways to do so, using
expiration
validation
invalidation
![Page 70: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/70.jpg)
and here are a few ways to do so, using
expiration
validation
invalidationwe will se why
![Page 71: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/71.jpg)
Expiration
![Page 72: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/72.jpg)
GET / HTTP/1.1Host: www.example.comExpires: 0
![Page 73: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/73.jpg)
GET / HTTP/1.1Host: www.example.comExpires: 0
![Page 74: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/74.jpg)
GET / HTTP/1.1Host: www.example.comExpires: Tue, 15 Nov 1994 01:00 GMT
![Page 75: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/75.jpg)
GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public
![Page 76: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/76.jpg)
GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public
![Page 77: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/77.jpg)
GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public
Cacheable for 60 seconds
![Page 78: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/78.jpg)
GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public
Cacheable by both local and shared caches
![Page 79: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/79.jpg)
GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600
![Page 80: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/80.jpg)
GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600
fault-tolerant
![Page 81: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/81.jpg)
GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600
available during downtime
![Page 82: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/82.jpg)
GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600
available during revalidation
![Page 83: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/83.jpg)
Validation
![Page 84: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/84.jpg)
GET / HTTP/1.1Host: www.example.comEtag: 1234
![Page 85: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/85.jpg)
GET / HTTP/1.1Host: www.example.comEtag: 1234
an identifier for your response
![Page 86: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/86.jpg)
GET / HTTP/1.1Host: www.example.comIf-None-Match: 1234
the browsers asks you if it has been modified
Conditional requests
![Page 87: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/87.jpg)
Relax
![Page 88: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/88.jpg)
Calculating an Etag is cheaper than generating a full MVC response
![Page 89: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/89.jpg)
HTTP/1.1 304 Not Modified
![Page 90: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/90.jpg)
GET / HTTP/1.1Host: www.example.comLast-Modified: Tue, 15 Jan 2011 12:00:00 GMT
![Page 91: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/91.jpg)
GET / HTTP/1.1Host: www.example.comLast-Modified: Tue, 15 Jan 2011 12:00:00 GMT
tell the client about the latest change
![Page 92: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/92.jpg)
GET / HTTP/1.1Host: www.example.comIf-Modified-Since: Tue, 15 Jan 2011 12:00:00 GMT
the client asks you if it has been modified since the last time
Conditional requests
![Page 93: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/93.jpg)
Relax
![Page 94: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/94.jpg)
Calculating a date is cheaper than retrieving an entire object
![Page 95: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/95.jpg)
HTTP/1.1 304 Not Modified
![Page 96: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/96.jpg)
Invalidation
![Page 97: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/97.jpg)
The web is not meant for invalidating data.
Server should not be able to keep clients' state, otherwise they wont scale well.
That's why long-polling and endless connections haven't had big success dealing with caching.
![Page 98: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/98.jpg)
but hey, you say
![Page 99: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/99.jpg)
HTTP's cache fails when dealing with really dynamic pages, because consumers will always have to hit the origin server, although a part of the page would be cacheable ( header and
footer, for example )
![Page 100: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/100.jpg)
Nope
Nope
![Page 102: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/102.jpg)
and hey, Varnish is a reverse proxy implementing what you need of the ESI specification
take 2, pay for 1
![Page 103: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/103.jpg)
So what does HTTP cache is meant to solve?
![Page 104: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/104.jpg)
Less work
![Page 105: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/105.jpg)
because the hard work is delegated to the browser/proxy
http://www.flickr.com/photos/snakphotography/5004775320/sizes/o/in/photostream/
![Page 106: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/106.jpg)
evolve
![Page 107: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/107.jpg)
because cache is abstracted from the application
![Page 108: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/108.jpg)
loose coupling
![Page 109: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/109.jpg)
because caching is bound to the protocol, HTTP, not to your implementation ( Sf, RoR, Django )
![Page 110: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/110.jpg)
The presentations lacks on technical stuff
So here are a few resource for who wants documentation:
http://tomayko.com/writings/things-caches-dohttp://www.slideshare.net/fabpot/caching-on-the-edgehttp://www.odino.org/301/rest-better-http-cachehttp://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
![Page 111: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/111.jpg)
Deep version of the same talk,about Sf2 cache internals and ESI
![Page 112: HTTP cache @ PUG Rome 03-29-2011](https://reader033.vdocuments.net/reader033/viewer/2022052618/554bc02cb4c90530298b500d/html5/thumbnails/112.jpg)
May, 12/14 2011 in Verona
Early bid ends on April, 6th