SlideShare a Scribd company logo
HTTP cache

   Alessandro Nadalin

    March, 29th 2011
The Web
     is
inconsistent
get over it
Why?
Because it scales to billions of
            users
Because it scales to billions of
            users

 WWW data traffic won't be
  possible without being
       inconsistent
How does it
  scales?
Cache
What is caching?
Storing data so that future requests for that data can be served
                                                           faster

                                             ( general purpose )
Process of storing copies of your most accessed resources near
                                            to a/some client/s

                                                ( the WWW )
Caching is not saving a webpage, or a fragment of it, on the
                          disk, to serve it to the next client
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
Disk-persisted or in-memory
Can be distributed
Can be distributed with a NoSQL database
Cache implementation can be really funny
Don't reinvent the
     wheel
Goals
Goals

        evolve
Goals

                 evolve
loose coupling
Goals
Work less
                             evolve
            loose coupling
Evolve

Because you want your platform to extensible
Evolve

Because you want your platform to extensible

                                                Loose coupling

Because you want it to be easy to integrate with, evolve, plug
and mantain
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
enters our Hero #1
HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011
enters our Hero #2
HTTP cache @ PUG Rome 03-29-2011
http://www.lullabot.com/articles/a-beginners-guide-to-caching-data
Goals
Work less
                             evolve
            loose coupling
Goals
Work less
                             evolve
            loose coupling
everything is done for us!

            :)



          but....
tmp files, cache tables, procedural crap...

               mmmmh....

        gotta be something better
Frameworks
HTTP cache @ PUG Rome 03-29-2011
Cache is used for compiling routes, autoloading, ...
Cache is used for compiling routes, autoloading, ...




   ...but also for storing the view
Goals
Work less
                             evolve
            loose coupling
Goals
Work less
                             evolve
            loose coupling
at least because we use a framework
but, probably
PHP sucks
Let's call a hero, from the East
on Rails
HTTP cache @ PUG Rome 03-29-2011
Goals
Work less
                             evolve
            loose coupling
gosh :-(
hey, what about
       the latest
      products?
both Symfony2 and
Ruby's Rack embrace
HTTP
(here comes the nice part)
Local

   Shared/proxy

Shared/reverse proxy
Local

   Shared/proxy

Shared/reverse proxy
HTTP cache @ PUG Rome 03-29-2011
Local

  Shared/proxy

Shared/reverse proxy
HTTP cache @ PUG Rome 03-29-2011
Local

    Shared/proxy

Shared/reverse proxy
HTTP cache @ PUG Rome 03-29-2011
on the server side
Proxy            Reverse proxy




        http://www.codeproject.com/KB/aspnet/ExploringCaching.aspx
There is something cool about
caching softwares.
Free as free beer
...but the server should
 take advantage of them
( the boring part were you need to write code )
and here are a few ways to do so,
using
and here are a few ways to do so,
using

           expiration
and here are a few ways to do so,
using

           expiration

           validation
and here are a few ways to do so,
using

           expiration

           validation

          invalidation
and here are a few ways to do so,
using

           expiration

           validation
                     we will se why
          invalidation
Expiration
GET / HTTP/1.1
Host: www.example.com
Expires: 0
GET / HTTP/1.1
Host: www.example.com
Expires: 0
GET / HTTP/1.1
Host: www.example.com
Expires: Tue, 15 Nov 1994 01:00 GMT
GET / HTTP/1.1
Host: www.example.com
Cache-Control: max-age=60, public
GET / HTTP/1.1
Host: www.example.com
Cache-Control: max-age=60, public
GET / HTTP/1.1
Host: www.example.com
Cache-Control: max-age=60, public


       Cacheable for 60 seconds
GET / HTTP/1.1
Host: www.example.com
Cache-Control: max-age=60, public


Cacheable by both local and shared caches
GET / HTTP/1.1
Host: www.example.com
Cache-Control: stale-if-error=600, stale-while-revalidate=600
GET / HTTP/1.1
Host: www.example.com
Cache-Control: stale-if-error=600, stale-while-revalidate=600




                        fault-tolerant
GET / HTTP/1.1
Host: www.example.com
Cache-Control: stale-if-error=600, stale-while-revalidate=600




                    available during downtime
GET / HTTP/1.1
Host: www.example.com
Cache-Control: stale-if-error=600, stale-while-revalidate=600




                  available during revalidation
Validation
GET / HTTP/1.1
Host: www.example.com
Etag: 1234
GET / HTTP/1.1
 Host: www.example.com
 Etag: 1234


an identifier for your response
Conditional requests

        GET / HTTP/1.1
        Host: www.example.com
        If-None-Match: 1234


the browsers asks you if it has been modified
Relax
Calculating an Etag is cheaper than generating a full MVC response
HTTP/1.1 304 Not Modified
GET / HTTP/1.1
Host: www.example.com
Last-Modified: Tue, 15 Jan 2011 12:00:00 GMT
GET / HTTP/1.1
Host: www.example.com
Last-Modified: Tue, 15 Jan 2011 12:00:00 GMT


          tell the client about the latest change
Conditional requests

GET / HTTP/1.1
Host: www.example.com
If-Modified-Since: Tue, 15 Jan 2011 12:00:00 GMT


  the client asks you if it has been modified since the last time
Relax
Calculating a date is cheaper than retrieving an entire object
HTTP/1.1 304 Not Modified
Invalidation
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.
but hey, you say
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 )
Nope


       Nope
ESI was built for that
     http://www.w3.org/TR/esi-lang
and hey, Varnish is a reverse proxy implementing what you
               need of the ESI specification

                    take 2, pay for 1
So what does HTTP cache is meant to solve?
Less work
http://www.flickr.com/photos/snakphotography/5004775320/sizes/o/in/photostream/




        because the hard work is delegated to the browser/proxy
evolve
because cache is abstracted from the application
loose coupling
because caching is bound to the protocol, HTTP, not
to your implementation ( Sf, RoR, Django )
The presentations lacks on technical stuff

So here are a few resource for who wants documentation:


  http://tomayko.com/writings/things-caches-do
  http://www.slideshare.net/fabpot/caching-on-the-edge
  http://www.odino.org/301/rest-better-http-cache
  http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
Deep version of the same talk,
about Sf2 cache internals and ESI
May, 12/14 2011 in Verona

Early bid ends on April, 6th
Thanks!

 Alessandro Nadalin
      @_odino_
      odino.org

More Related Content

What's hot (20)

PPTX
NGINX Installation and Tuning
NGINX, Inc.
 
PPTX
High Availability Content Caching with NGINX
NGINX, Inc.
 
PDF
Lcu14 Lightning Talk- NGINX
Linaro
 
PPTX
What's New in NGINX Plus R7?
NGINX, Inc.
 
PPTX
Drupal 8 and NGINX
NGINX, Inc.
 
PPTX
Learn nginx in 90mins
Larry Cai
 
PPTX
Supercharge Application Delivery to Satisfy Users
NGINX, Inc.
 
PPTX
Introduction to NGINX web server
Md Waresul Islam
 
KEY
Nginx in production
Graham Weldon
 
PPTX
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX, Inc.
 
PPTX
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Amit Aggarwal
 
PDF
How to Run a 1,000,000 VU Load Test using Apache JMeter and BlazeMeter
Alon Girmonsky
 
PPTX
how to mesure web performance metrics
Marc Cortinas Val
 
PPTX
Delivering High Performance Websites with NGINX
NGINX, Inc.
 
PDF
Altitude SF 2017: Advanced VCL: Shielding and Clustering
Fastly
 
PPTX
Altitude SF 2017: Fastly GSLB: Scaling your microservice and multi-cloud envi...
Fastly
 
PPTX
NGINX: Basics and Best Practices
NGINX, Inc.
 
PDF
Altitude SF 2017: Debugging Fastly VCL 101
Fastly
 
PDF
Altitude SF 2017: The power of the network
Fastly
 
KEY
Performance Tuning - MuraCon 2012
eballisty
 
NGINX Installation and Tuning
NGINX, Inc.
 
High Availability Content Caching with NGINX
NGINX, Inc.
 
Lcu14 Lightning Talk- NGINX
Linaro
 
What's New in NGINX Plus R7?
NGINX, Inc.
 
Drupal 8 and NGINX
NGINX, Inc.
 
Learn nginx in 90mins
Larry Cai
 
Supercharge Application Delivery to Satisfy Users
NGINX, Inc.
 
Introduction to NGINX web server
Md Waresul Islam
 
Nginx in production
Graham Weldon
 
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX, Inc.
 
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Amit Aggarwal
 
How to Run a 1,000,000 VU Load Test using Apache JMeter and BlazeMeter
Alon Girmonsky
 
how to mesure web performance metrics
Marc Cortinas Val
 
Delivering High Performance Websites with NGINX
NGINX, Inc.
 
Altitude SF 2017: Advanced VCL: Shielding and Clustering
Fastly
 
Altitude SF 2017: Fastly GSLB: Scaling your microservice and multi-cloud envi...
Fastly
 
NGINX: Basics and Best Practices
NGINX, Inc.
 
Altitude SF 2017: Debugging Fastly VCL 101
Fastly
 
Altitude SF 2017: The power of the network
Fastly
 
Performance Tuning - MuraCon 2012
eballisty
 

Similar to HTTP cache @ PUG Rome 03-29-2011 (20)

ODP
MNPHP Scalable Architecture 101 - Feb 3 2011
Mike Willbanks
 
PDF
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
Alessandro Nadalin
 
PDF
Scaling PHP apps
Matteo Moretti
 
PPT
Apache Traffic Server
supertom
 
ODP
Drupal Performance and Scaling
Gerald Villorente
 
PPTX
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
edm00se
 
PPS
Web20expo Scalable Web Arch
guest18a0f1
 
PPS
Web20expo Scalable Web Arch
mclee
 
PPS
Web20expo Scalable Web Arch
royans
 
PPTX
Joomla! Performance on Steroids
SiteGround.com
 
PPTX
JS digest. Decemebr 2017
ElifTech
 
PPT
Lamp Stack Optimization
Dave Ross
 
KEY
Site Performance - From Pinto to Ferrari
Joseph Scott
 
PPT
Web Speed And Scalability
Jason Ragsdale
 
PPT
Hyper v r2 deep dive
Concentrated Technology
 
PPS
Scalable Web Arch
royans
 
PPS
Scalable Web Architectures - Common Patterns & Approaches
Cal Henderson
 
PDF
Improving The Performance of Your Web App
Joe Stump
 
PPTX
High Performance Sites with Drupal and Cache Control Module
Exove
 
PDF
DrupalCampLA 2011: Drupal backend-performance
Ashok Modi
 
MNPHP Scalable Architecture 101 - Feb 3 2011
Mike Willbanks
 
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
Alessandro Nadalin
 
Scaling PHP apps
Matteo Moretti
 
Apache Traffic Server
supertom
 
Drupal Performance and Scaling
Gerald Villorente
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
edm00se
 
Web20expo Scalable Web Arch
guest18a0f1
 
Web20expo Scalable Web Arch
mclee
 
Web20expo Scalable Web Arch
royans
 
Joomla! Performance on Steroids
SiteGround.com
 
JS digest. Decemebr 2017
ElifTech
 
Lamp Stack Optimization
Dave Ross
 
Site Performance - From Pinto to Ferrari
Joseph Scott
 
Web Speed And Scalability
Jason Ragsdale
 
Hyper v r2 deep dive
Concentrated Technology
 
Scalable Web Arch
royans
 
Scalable Web Architectures - Common Patterns & Approaches
Cal Henderson
 
Improving The Performance of Your Web App
Joe Stump
 
High Performance Sites with Drupal and Cache Control Module
Exove
 
DrupalCampLA 2011: Drupal backend-performance
Ashok Modi
 
Ad

More from Alessandro Nadalin (20)

PDF
Spa, isomorphic and back to the server our journey with js @ frontend con po...
Alessandro Nadalin
 
PDF
SPA, isomorphic and back to the server: our journey with JavaScript @ JsDay 2...
Alessandro Nadalin
 
PDF
Scaling at Namshi @ Seamless Ecommerce Dubai 2017
Alessandro Nadalin
 
PDF
Accelerated Mobile Pages @ Dubytes meetup Dec 2016 in Dubai
Alessandro Nadalin
 
PDF
A tech team of ~10 @ Rocket Tech Summit 2016 in Berlin
Alessandro Nadalin
 
PDF
React native in the wild @ Codemotion 2016 in Rome
Alessandro Nadalin
 
PDF
Dockerize it! @ Codemotion 2016 in Rome
Alessandro Nadalin
 
PDF
Deploying 3 times a day without a downtime @ Rocket Tech Summit in Berlin
Alessandro Nadalin
 
PDF
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Alessandro Nadalin
 
PDF
Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)
Alessandro Nadalin
 
PDF
Namshi in 2014: let's rock!
Alessandro Nadalin
 
PDF
Angular js is the future. maybe. @ ConFoo 2014 in Montreal (CA)
Alessandro Nadalin
 
PDF
OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...
Alessandro Nadalin
 
PDF
A Rocket Internet experience @ ForumPHP Paris 2013
Alessandro Nadalin
 
PDF
HTTP colon slash slash: end of the road? @ CakeFest 2013 in San Francisco
Alessandro Nadalin
 
PDF
Tips and Tricks for your Service Oriented Architecture @ CakeFest 2013 in San...
Alessandro Nadalin
 
PDF
The rocket internet experience @ PHP.TO.START 2013 in Turin
Alessandro Nadalin
 
PDF
GraphDB in PHP @ Codemotion 03/23/2012
Alessandro Nadalin
 
PDF
REST in peace @ IPC 2012 in Mainz
Alessandro Nadalin
 
PDF
HTTP colon slash slash: the end of the road?
Alessandro Nadalin
 
Spa, isomorphic and back to the server our journey with js @ frontend con po...
Alessandro Nadalin
 
SPA, isomorphic and back to the server: our journey with JavaScript @ JsDay 2...
Alessandro Nadalin
 
Scaling at Namshi @ Seamless Ecommerce Dubai 2017
Alessandro Nadalin
 
Accelerated Mobile Pages @ Dubytes meetup Dec 2016 in Dubai
Alessandro Nadalin
 
A tech team of ~10 @ Rocket Tech Summit 2016 in Berlin
Alessandro Nadalin
 
React native in the wild @ Codemotion 2016 in Rome
Alessandro Nadalin
 
Dockerize it! @ Codemotion 2016 in Rome
Alessandro Nadalin
 
Deploying 3 times a day without a downtime @ Rocket Tech Summit in Berlin
Alessandro Nadalin
 
Hey, I just met AngularJS, and this is crazy, so here’s my JavaScript, let’s ...
Alessandro Nadalin
 
Don't screw it up: how to build durable web apis @ PHPDay 2014 in Verona (ITA)
Alessandro Nadalin
 
Namshi in 2014: let's rock!
Alessandro Nadalin
 
Angular js is the future. maybe. @ ConFoo 2014 in Montreal (CA)
Alessandro Nadalin
 
OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...
Alessandro Nadalin
 
A Rocket Internet experience @ ForumPHP Paris 2013
Alessandro Nadalin
 
HTTP colon slash slash: end of the road? @ CakeFest 2013 in San Francisco
Alessandro Nadalin
 
Tips and Tricks for your Service Oriented Architecture @ CakeFest 2013 in San...
Alessandro Nadalin
 
The rocket internet experience @ PHP.TO.START 2013 in Turin
Alessandro Nadalin
 
GraphDB in PHP @ Codemotion 03/23/2012
Alessandro Nadalin
 
REST in peace @ IPC 2012 in Mainz
Alessandro Nadalin
 
HTTP colon slash slash: the end of the road?
Alessandro Nadalin
 
Ad

Recently uploaded (20)

PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 

HTTP cache @ PUG Rome 03-29-2011

Editor's Notes

  • #19: Ne consegue che non dobbiamo reinventare sempre la ruota.