SlideShare a Scribd company logo
1 of 146
Frontend Caching


                                  Helgi Þormar Þorbjörnsson
                          PHP Community Con, Nashville, 21st April 2011

Friday, 22 April 2011
Who am I?

                        VP of Engineering at Orchestra.io
                        Developer at PEAR
                        From Iceland
                        @h on Twitter



Friday, 22 April 2011
Pareto Principle


                            20%   80%




Friday, 22 April 2011
80 / 20 Rule


                              20%       80%
                 20% of sales people produce 80% of sales




Friday, 22 April 2011
80 / 20 Rule


                   20%         80%
   20% of the population receives 80% of the income




Friday, 22 April 2011
80 / 20 Rule


                              20%       80%
                  20% of causes produce 80% of the effects




Friday, 22 April 2011
80% of response time is
                        spent downloading resources




Friday, 22 April 2011
4 Rules of Web
                         Performance


Friday, 22 April 2011
Weight
                          Time
                        Processing
                        Perception

Friday, 22 April 2011
Perception



Friday, 22 April 2011
Make people think your site is fast




Friday, 22 April 2011
When people can interact with the site




Friday, 22 April 2011
Friday, 22 April 2011
“It all depends on how we
                        look at things, and not how
                          they are in themselves.”
                                      - Carl G. Jung




Friday, 22 April 2011
Perception


                        50% of users arrive
                             on an empty cache




Friday, 22 April 2011
Perception

                         Empty Cache                    Full Cache
                        28.0K    1 HTML Document

                         1.9K    1 Style Sheet File

                        59.5K    4 Javascript Files   28.0K   1 HTML Document
                        78.7K    24 Images            0.1K    2 Images
                        168.1K   Total Size           28.1K   Total Size
                         30      HTTP Requests         3      HTTP Requests
                         2.4s    Response Time        0.9s    Response Time




Friday, 22 April 2011
Weight



Friday, 22 April 2011
HTTP Requests




Friday, 22 April 2011
HTTP Requests

                        Less is more




Friday, 22 April 2011
HTTP Requests

                        Less is more
                        Fewer HTTP Requests




Friday, 22 April 2011
HTTP Requests

                        Less is more
                        Fewer HTTP Requests
                        Easy to improve on




Friday, 22 April 2011
Cookies




Friday, 22 April 2011
Cookies

                        Sent with static content




Friday, 22 April 2011
Cookies

                        Sent with static content
                          Slow upstream speed




Friday, 22 April 2011
Cookies

                        Sent with static content
                          Slow upstream speed
                                    Big cookies




Friday, 22 April 2011
Experiment Time!
                                    Cookie Size     Response Time (Delta)
                          0 bytes                 78 ms ( 0 ms)
                          500 bytes               79 ms ( +1 ms)
                          1000 bytes              94 ms (+16 ms)
                          1500 bytes              109 ms (+31 ms)
                          2000 bytes              125 ms (+47 ms)
                          2500 bytes              141 ms (+63 ms)
                          3000 bytes              156 ms (+78 ms)




Friday, 22 April 2011
Cookies




Friday, 22 April 2011
Cookies




Friday, 22 April 2011
Cookies
                        Remove unnecessary cookies




Friday, 22 April 2011
Cookies
                        Remove unnecessary cookies
                        Appropriate domain level




Friday, 22 April 2011
Cookies
                        Remove unnecessary cookies
                        Appropriate domain level
                        Keep size low




Friday, 22 April 2011
Cookies
                        Remove unnecessary cookies
                        Appropriate domain level
                        Keep size low
                        Set Expires




Friday, 22 April 2011
Parallel Downloads




Friday, 22 April 2011
Parallel Downloads

                        Be aware of max connection limits




Friday, 22 April 2011
Parallel Downloads

                            Be aware of max connection limits

                   CNAME to point multiple sub domains to the same IP




Friday, 22 April 2011
Parallel Downloads

                            Be aware of max connection limits

                   CNAME to point multiple sub domains to the same IP




Friday, 22 April 2011
Parallel Downloads




                        Borrowed from BrowserScope.org

Friday, 22 April 2011
Parallel Downloads




                        Borrowed from BrowserScope.org

Friday, 22 April 2011
Parallel Downloads


                        One domain = 2 Parallel connections




Friday, 22 April 2011
Parallel Downloads
                        One domain = 2 Parallel connections

                         HTML
                         Image
                         Image
                         Image
                         Image
                         Image
                         Image
                         Image
                         Image

                                 0.4   0.8   1.2   1.6   2   2.4   Secs



Friday, 22 April 2011
Parallel Downloads
                        Two domains = 4 Parallel connections

                          HTML
                         Image
                         Image
                         Image
                         Image
                         Image
                         Image
                         Image
                         Image

                                 0.4   0.8   1.2   1.6   2   2.4   Secs



Friday, 22 April 2011
Parallel Downloads

                        Too many hostnames can cause complications




Friday, 22 April 2011
Parallel Downloads

                        Too many hostnames can cause complications



                          2 – 4 sub domains is a good average




Friday, 22 April 2011
Combine Files

                    Combining 6 scripts into 1 eliminates 5 requests




Friday, 22 April 2011
Combine Files

                    Combining 6 scripts into 1 eliminates 5 requests

                        Challenges:
                          develop as separate modules
                          combinations vs. loading more than needed




Friday, 22 April 2011
Javascript


                         Doesn’t comply with
                        parallel download rules




Friday, 22 April 2011
Javascript
                               Doesn’t comply with
                              parallel download rules
                        HTML
                         JS
                        Image
                        Image
                        Image
                        Image
                        Image
                        Image
                        Image

                                0.4   0.8   1.2   1.6   2   2.4   Secs


Friday, 22 April 2011
Javascript
                        script defer attribute is not a solution




Friday, 22 April 2011
Javascript
                        script defer attribute is not a solution

                        Solution - move them as low in the
                                          page as possible




Friday, 22 April 2011
Processing



Friday, 22 April 2011
Processing




Friday, 22 April 2011
Processing

                        Fake the delivery




Friday, 22 April 2011
Processing

                        Fake the delivery
                        Lazy Loading




Friday, 22 April 2011
Processing

                        Fake the delivery
                        Lazy Loading
                        Above the fold Loading




Friday, 22 April 2011
Processing

                        Fake the delivery
                        Lazy Loading
                        Above the fold Loading
                        Delay Javascript Loading



Friday, 22 April 2011
Processing


                http://www.appelsiini.net/projects/lazyload




Friday, 22 April 2011
Processing
                        Bonus - async attribute


                http://www.appelsiini.net/projects/lazyload




Friday, 22 April 2011
JS Minification




Friday, 22 April 2011
JS Minification

                            Crushes the file
                           Strips out all cruft
                            Voodoo Magic!




Friday, 22 April 2011
JS Minfication
                         UglifyJS
                         Google Closure
                         YUI Compressor
                         Dojo Shrinksafe
                         JSMin


Friday, 22 April 2011
JS Minfication
                           UglifyJS
                           Google Closure
                           YUI Compressor
                           Dojo Shrinksafe
                           JSMin

                        http://bit.ly/compression-rates
Friday, 22 April 2011
CSS Minification

                           YUI Compressor
                           minifycss.com
                           OOCSS




Friday, 22 April 2011
GZip
                        GZip can be used on
                            JS
                            CSS
                            XML
                            JSON




Friday, 22 April 2011
GZip
                        GZip should not be used on

                            Images
                            Document formats
                            Already compressed




Friday, 22 April 2011
404


                        robots.txt
                         favicon




Friday, 22 April 2011
Images




Friday, 22 April 2011
Images

                         favicon




Friday, 22 April 2011
Images

                         favicon
                        CSS Sprites




Friday, 22 April 2011
Images

                         favicon
                        CSS Sprites




Friday, 22 April 2011
Sprites




Friday, 22 April 2011
Sprites
                        Reduces HTTP Requests




Friday, 22 April 2011
Sprites
                        Reduces HTTP Requests
                        Uses CSS Position magic




Friday, 22 April 2011
Sprites
                        Reduces HTTP Requests
                        Uses CSS Position magic
                        Hard to maintain long term




Friday, 22 April 2011
Sprites
                        Reduces HTTP Requests
                        Uses CSS Position magic
                        Hard to maintain long term
                        Time sink




Friday, 22 April 2011
Sprites
                        Reduces HTTP Requests
                        Uses CSS Position magic
                        Hard to maintain long term
                        Time sink
                        Too much magic


Friday, 22 April 2011
Resource Packages




Friday, 22 April 2011
Resource Packages
                        JAR file that contains everything




Friday, 22 April 2011
Resource Packages
                        JAR file that contains everything
                        Compresses




Friday, 22 April 2011
Resource Packages
                        JAR file that contains everything
                        Compresses
                        Accesses individual resources




Friday, 22 April 2011
Resource Packages
                        JAR file that contains everything
                        Compresses
                        Accesses individual resources
                        Easy to maintain




Friday, 22 April 2011
Resource Packages
                        JAR file that contains everything
                        Compresses
                        Accesses individual resources
                        Easy to maintain
                        New Proposal in the works


Friday, 22 April 2011
Images

                        Badly optimised
                        Thumbnails
                        PNGs compressed up to 50%




Friday, 22 April 2011
PNG Optimise

                            OptiPNG
                            pngwolf
                            pngcrush
                            jpegtran



Friday, 22 April 2011
Time



Friday, 22 April 2011
SSL




Friday, 22 April 2011
SSL

                        Extra roundtrips




Friday, 22 April 2011
SSL

                        Extra roundtrips
                        More resources for servers




Friday, 22 April 2011
SSL

                        Extra roundtrips
                        More resources for servers
                        Worth it, tho!




Friday, 22 April 2011
Tread the users’ path


                        Test on slower connections
                        Slow proxies




Friday, 22 April 2011
Tread the users’ path

                        Tables / Phones
                        Airline connections
                        Public places




Friday, 22 April 2011
CDN

                        Single domain
                        Smart routing
                        Data is closer to end user




Friday, 22 April 2011
CDN




Friday, 22 April 2011
CDN




Friday, 22 April 2011
CDN on a Budget


                             S3

Friday, 22 April 2011
Expires Headers
                         Last-Modified
                         Appropriate Dates
                         Cache far in the future
                         Change file names




Friday, 22 April 2011
ETags

                        Hash Tag
                        Cache vs Server
                        More flexible than dates
                        Good for Single Server



Friday, 22 April 2011
Problems




Friday, 22 April 2011
Problems


                        Typically unique per server




Friday, 22 April 2011
Problems


                        Typically unique per server

                        Disable if not used



Friday, 22 April 2011
Farms

                        Use options that are not
                        unique per server




Friday, 22 April 2011
Reverse Proxies




Friday, 22 April 2011
Reverse Proxies

                            Varnish
                            Nginx
                            Squid




Friday, 22 April 2011
Query vs. Filename
                        revisions




Friday, 22 April 2011
Query vs. Filename
                        revisions
                        Cache far in future




Friday, 22 April 2011
Query vs. Filename
                        revisions
                        Cache far in future
                        Revisioning forces downloads




Friday, 22 April 2011
Query vs. Filename
                        revisions
                        Cache far in future
                        Revisioning forces downloads




Friday, 22 April 2011
Query revisions




Friday, 22 April 2011
Query revisions

                        Easy and convenient




Friday, 22 April 2011
Query revisions

                        Easy and convenient
                        Usually not recommended




Friday, 22 April 2011
Query revisions

                        Easy and convenient
                        Usually not recommended
                        Bad proxies are a problem




Friday, 22 April 2011
Filename revisions




Friday, 22 April 2011
Filename revisions

                         Requires more work




Friday, 22 April 2011
Filename revisions

                         Requires more work
                         Recommended




Friday, 22 April 2011
Filename revisions

                         Requires more work
                         Recommended
                         During build, using md5 hash




Friday, 22 April 2011
Compromise




Friday, 22 April 2011
Compromise
                        Create a version function




Friday, 22 April 2011
Compromise
                        Create a version function
                        Put on all resources




Friday, 22 April 2011
Compromise
                        Create a version function
                        Put on all resources
                        mod_rewrite magic




Friday, 22 April 2011
Compromise
                        Create a version function
                        Put on all resources
                        mod_rewrite magic


                        http://bit.ly/query_rev_comp
Friday, 22 April 2011
Compromise
                        Create a version function
                        Put on all resources
                        mod_rewrite magic


                        http://bit.ly/query_rev_comp
Friday, 22 April 2011
Browser Tools




Friday, 22 April 2011
Browser Tools

                         Firebug




Friday, 22 April 2011
Browser Tools

                         Firebug
                         YSlow




Friday, 22 April 2011
Browser Tools

                         Firebug
                         YSlow
                         PageSpeed




Friday, 22 April 2011
Browser Tools

                         Firebug
                         YSlow
                         PageSpeed
                         Chrome Inspector



Friday, 22 April 2011
Other Tools




Friday, 22 April 2011
Other Tools
                        HTTPWatch.com




Friday, 22 April 2011
Other Tools
                        HTTPWatch.com
                        WebPageTest.org




Friday, 22 April 2011
Other Tools
                        HTTPWatch.com
                        WebPageTest.org
                        HTTPArchive.org




Friday, 22 April 2011
Other Tools
                        HTTPWatch.com
                        WebPageTest.org
                        HTTPArchive.org
                        Yottaa.com




Friday, 22 April 2011
Other Tools
                        HTTPWatch.com
                        WebPageTest.org
                        HTTPArchive.org
                        Yottaa.com
                        WonderProxy.com


Friday, 22 April 2011
Other Tools
                        HTTPWatch.com
                        WebPageTest.org
                        HTTPArchive.org
                        Yottaa.com
                        WonderProxy.com
                        pagespeed.googlelabs.com

Friday, 22 April 2011
Other Tools




Friday, 22 April 2011
Other Tools

                        WonderProxy.com




Friday, 22 April 2011
Other Tools

                        WonderProxy.com
                        pagespeed.googlelabs.com




Friday, 22 April 2011
Other Tools

                        WonderProxy.com
                        pagespeed.googlelabs.com
                        BrowserScope.com




Friday, 22 April 2011
Other Tools

                        WonderProxy.com
                        pagespeed.googlelabs.com
                        BrowserScope.com
                        html5boilerplate.com


Friday, 22 April 2011
Interesting Project




Friday, 22 April 2011
Interesting Project
                            Diffable




Friday, 22 April 2011
Interesting Project
                              Diffable
                           Uses deltas




Friday, 22 April 2011
Interesting Project
                              Diffable
                           Uses deltas
                           Transfer only the diff




Friday, 22 April 2011
Interesting Project
                              Diffable
                           Uses deltas
                           Transfer only the diff
                           Can be used on JS and CSS




Friday, 22 April 2011
Interesting Project
                                Diffable
                             Uses deltas
                             Transfer only the diff
                             Can be used on JS and CSS



                         http://code.google.com/p/diffable/
Friday, 22 April 2011
“Knowledge rests not upon truth
                          alone, but upon error also”
                                          - Carl G. Jung




Friday, 22 April 2011
Demo Time!



Friday, 22 April 2011
Questions?


                  helgi@orchestra.io
                  Twitter: @h



                        Joind.in: http://joind.in/3340
Friday, 22 April 2011

More Related Content

Similar to Frontend caching

Gradle - The hackable build-tool
Gradle - The hackable build-toolGradle - The hackable build-tool
Gradle - The hackable build-toolLeonard Axelsson
 
the role of the future academic library...
the role of the future academic library...the role of the future academic library...
the role of the future academic library...Penny Hagen
 
Public days swedisch broadcasting presentation Vincent
Public days swedisch broadcasting presentation VincentPublic days swedisch broadcasting presentation Vincent
Public days swedisch broadcasting presentation VincentVincent Everts
 
Form project why is the sky blue and other questions
Form project  why is the sky blue and other questionsForm project  why is the sky blue and other questions
Form project why is the sky blue and other questionsaakashm
 
20110721 pankaku us
20110721 pankaku us20110721 pankaku us
20110721 pankaku us01Booster
 
The Productive Researcher's Technology Toolbox
The Productive Researcher's Technology ToolboxThe Productive Researcher's Technology Toolbox
The Productive Researcher's Technology ToolboxStratepedia Presentations
 
Vrom presentatie slim bouwen & sociale media
Vrom presentatie slim bouwen & sociale mediaVrom presentatie slim bouwen & sociale media
Vrom presentatie slim bouwen & sociale mediaVincent Everts
 
Mozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMOMozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMOMatt Brandt
 
PyconUA - How to build ERP application having fun?
PyconUA - How to build ERP application having fun?PyconUA - How to build ERP application having fun?
PyconUA - How to build ERP application having fun?Andrew Mleczko
 
Distributed Backups for friends and communities
Distributed Backups for friends and communitiesDistributed Backups for friends and communities
Distributed Backups for friends and communitiesAde Oshineye
 
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias SociaisExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias SociaisDOGSCAMP Summit
 
clipperz @ JSE2011
clipperz @ JSE2011clipperz @ JSE2011
clipperz @ JSE2011gcsolaroli
 
Donating a mature project to Eclipse
Donating a mature project to EclipseDonating a mature project to Eclipse
Donating a mature project to Eclipseglynnormington
 
Sony benelux & social media
Sony benelux & social mediaSony benelux & social media
Sony benelux & social mediaVincent Everts
 

Similar to Frontend caching (18)

Gradle - The hackable build-tool
Gradle - The hackable build-toolGradle - The hackable build-tool
Gradle - The hackable build-tool
 
Jono mozilla-talk
Jono mozilla-talkJono mozilla-talk
Jono mozilla-talk
 
the role of the future academic library...
the role of the future academic library...the role of the future academic library...
the role of the future academic library...
 
Public days swedisch broadcasting presentation Vincent
Public days swedisch broadcasting presentation VincentPublic days swedisch broadcasting presentation Vincent
Public days swedisch broadcasting presentation Vincent
 
Form project why is the sky blue and other questions
Form project  why is the sky blue and other questionsForm project  why is the sky blue and other questions
Form project why is the sky blue and other questions
 
20110721 pankaku us
20110721 pankaku us20110721 pankaku us
20110721 pankaku us
 
The Productive Researcher's Technology Toolbox
The Productive Researcher's Technology ToolboxThe Productive Researcher's Technology Toolbox
The Productive Researcher's Technology Toolbox
 
Vrom presentatie slim bouwen & sociale media
Vrom presentatie slim bouwen & sociale mediaVrom presentatie slim bouwen & sociale media
Vrom presentatie slim bouwen & sociale media
 
Mozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMOMozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMO
 
PyconUA - How to build ERP application having fun?
PyconUA - How to build ERP application having fun?PyconUA - How to build ERP application having fun?
PyconUA - How to build ERP application having fun?
 
clrh58
clrh58clrh58
clrh58
 
Distributed Backups for friends and communities
Distributed Backups for friends and communitiesDistributed Backups for friends and communities
Distributed Backups for friends and communities
 
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias SociaisExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
 
clipperz @ JSE2011
clipperz @ JSE2011clipperz @ JSE2011
clipperz @ JSE2011
 
Donating a mature project to Eclipse
Donating a mature project to EclipseDonating a mature project to Eclipse
Donating a mature project to Eclipse
 
Frontend caching - PHP Day, Italy, 2011
Frontend caching - PHP Day, Italy, 2011Frontend caching - PHP Day, Italy, 2011
Frontend caching - PHP Day, Italy, 2011
 
Sony benelux & social media
Sony benelux & social mediaSony benelux & social media
Sony benelux & social media
 
Distribute the workload, PHPTek, Amsterdam, 2011
Distribute the workload, PHPTek, Amsterdam, 2011Distribute the workload, PHPTek, Amsterdam, 2011
Distribute the workload, PHPTek, Amsterdam, 2011
 

More from Helgi Þormar Þorbjörnsson

Scale like an ant, distribute the workload - DPC, Amsterdam, 2011
Scale like an ant, distribute the workload - DPC, Amsterdam,  2011Scale like an ant, distribute the workload - DPC, Amsterdam,  2011
Scale like an ant, distribute the workload - DPC, Amsterdam, 2011Helgi Þormar Þorbjörnsson
 
Think like an ant, distribute the workload - PhpDay, Italy, 2011
Think like an ant, distribute the workload - PhpDay, Italy, 2011Think like an ant, distribute the workload - PhpDay, Italy, 2011
Think like an ant, distribute the workload - PhpDay, Italy, 2011Helgi Þormar Þorbjörnsson
 
Plant Pyrus in your system - A guide to a plugin system.
Plant Pyrus in your system - A guide to a plugin system.Plant Pyrus in your system - A guide to a plugin system.
Plant Pyrus in your system - A guide to a plugin system.Helgi Þormar Þorbjörnsson
 
Website releases made easy with the PEAR installer, OSCON 2009
Website releases made easy with the PEAR installer, OSCON 2009Website releases made easy with the PEAR installer, OSCON 2009
Website releases made easy with the PEAR installer, OSCON 2009Helgi Þormar Þorbjörnsson
 
Website releases made easy with the PEAR installer - Barcelona 2008
Website releases made easy with the PEAR installer - Barcelona 2008Website releases made easy with the PEAR installer - Barcelona 2008
Website releases made easy with the PEAR installer - Barcelona 2008Helgi Þormar Þorbjörnsson
 

More from Helgi Þormar Þorbjörnsson (14)

Phar, The PHP .exe Format
Phar, The PHP .exe FormatPhar, The PHP .exe Format
Phar, The PHP .exe Format
 
Distribute the workload, PHP Barcelona 2011
Distribute the workload, PHP Barcelona 2011Distribute the workload, PHP Barcelona 2011
Distribute the workload, PHP Barcelona 2011
 
Scale like an ant, distribute the workload - DPC, Amsterdam, 2011
Scale like an ant, distribute the workload - DPC, Amsterdam,  2011Scale like an ant, distribute the workload - DPC, Amsterdam,  2011
Scale like an ant, distribute the workload - DPC, Amsterdam, 2011
 
Think like an ant, distribute the workload - PhpDay, Italy, 2011
Think like an ant, distribute the workload - PhpDay, Italy, 2011Think like an ant, distribute the workload - PhpDay, Italy, 2011
Think like an ant, distribute the workload - PhpDay, Italy, 2011
 
Plant Pyrus in your system - A guide to a plugin system.
Plant Pyrus in your system - A guide to a plugin system.Plant Pyrus in your system - A guide to a plugin system.
Plant Pyrus in your system - A guide to a plugin system.
 
PEAR2 & Pyrus - The look ahead
PEAR2 & Pyrus - The look aheadPEAR2 & Pyrus - The look ahead
PEAR2 & Pyrus - The look ahead
 
Frontend Caching - The "new" frontier
Frontend Caching - The "new" frontierFrontend Caching - The "new" frontier
Frontend Caching - The "new" frontier
 
Caching for Cash, part 4 DPC 2009
Caching for Cash, part 4 DPC 2009Caching for Cash, part 4 DPC 2009
Caching for Cash, part 4 DPC 2009
 
Cashing For Cash, part 1 DPC 2009
Cashing For Cash, part 1 DPC 2009Cashing For Cash, part 1 DPC 2009
Cashing For Cash, part 1 DPC 2009
 
Website releases made easy with the PEAR installer, OSCON 2009
Website releases made easy with the PEAR installer, OSCON 2009Website releases made easy with the PEAR installer, OSCON 2009
Website releases made easy with the PEAR installer, OSCON 2009
 
Caching for Cash - Part 4
Caching for Cash - Part 4Caching for Cash - Part 4
Caching for Cash - Part 4
 
Caching for Cash - Part 1
Caching for Cash - Part 1Caching for Cash - Part 1
Caching for Cash - Part 1
 
Coping with Cyber Monday
Coping with Cyber MondayCoping with Cyber Monday
Coping with Cyber Monday
 
Website releases made easy with the PEAR installer - Barcelona 2008
Website releases made easy with the PEAR installer - Barcelona 2008Website releases made easy with the PEAR installer - Barcelona 2008
Website releases made easy with the PEAR installer - Barcelona 2008
 

Recently uploaded

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Recently uploaded (20)

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Frontend caching

  • 1. Frontend Caching Helgi Þormar Þorbjörnsson PHP Community Con, Nashville, 21st April 2011 Friday, 22 April 2011
  • 2. Who am I? VP of Engineering at Orchestra.io Developer at PEAR From Iceland @h on Twitter Friday, 22 April 2011
  • 3. Pareto Principle 20% 80% Friday, 22 April 2011
  • 4. 80 / 20 Rule 20% 80% 20% of sales people produce 80% of sales Friday, 22 April 2011
  • 5. 80 / 20 Rule 20% 80% 20% of the population receives 80% of the income Friday, 22 April 2011
  • 6. 80 / 20 Rule 20% 80% 20% of causes produce 80% of the effects Friday, 22 April 2011
  • 7. 80% of response time is spent downloading resources Friday, 22 April 2011
  • 8. 4 Rules of Web Performance Friday, 22 April 2011
  • 9. Weight Time Processing Perception Friday, 22 April 2011
  • 11. Make people think your site is fast Friday, 22 April 2011
  • 12. When people can interact with the site Friday, 22 April 2011
  • 14. “It all depends on how we look at things, and not how they are in themselves.” - Carl G. Jung Friday, 22 April 2011
  • 15. Perception 50% of users arrive on an empty cache Friday, 22 April 2011
  • 16. Perception Empty Cache Full Cache 28.0K 1 HTML Document 1.9K 1 Style Sheet File 59.5K 4 Javascript Files 28.0K 1 HTML Document 78.7K 24 Images 0.1K 2 Images 168.1K Total Size 28.1K Total Size 30 HTTP Requests 3 HTTP Requests 2.4s Response Time 0.9s Response Time Friday, 22 April 2011
  • 19. HTTP Requests Less is more Friday, 22 April 2011
  • 20. HTTP Requests Less is more Fewer HTTP Requests Friday, 22 April 2011
  • 21. HTTP Requests Less is more Fewer HTTP Requests Easy to improve on Friday, 22 April 2011
  • 23. Cookies Sent with static content Friday, 22 April 2011
  • 24. Cookies Sent with static content Slow upstream speed Friday, 22 April 2011
  • 25. Cookies Sent with static content Slow upstream speed Big cookies Friday, 22 April 2011
  • 26. Experiment Time! Cookie Size Response Time (Delta) 0 bytes 78 ms ( 0 ms) 500 bytes 79 ms ( +1 ms) 1000 bytes 94 ms (+16 ms) 1500 bytes 109 ms (+31 ms) 2000 bytes 125 ms (+47 ms) 2500 bytes 141 ms (+63 ms) 3000 bytes 156 ms (+78 ms) Friday, 22 April 2011
  • 29. Cookies Remove unnecessary cookies Friday, 22 April 2011
  • 30. Cookies Remove unnecessary cookies Appropriate domain level Friday, 22 April 2011
  • 31. Cookies Remove unnecessary cookies Appropriate domain level Keep size low Friday, 22 April 2011
  • 32. Cookies Remove unnecessary cookies Appropriate domain level Keep size low Set Expires Friday, 22 April 2011
  • 34. Parallel Downloads Be aware of max connection limits Friday, 22 April 2011
  • 35. Parallel Downloads Be aware of max connection limits CNAME to point multiple sub domains to the same IP Friday, 22 April 2011
  • 36. Parallel Downloads Be aware of max connection limits CNAME to point multiple sub domains to the same IP Friday, 22 April 2011
  • 37. Parallel Downloads Borrowed from BrowserScope.org Friday, 22 April 2011
  • 38. Parallel Downloads Borrowed from BrowserScope.org Friday, 22 April 2011
  • 39. Parallel Downloads One domain = 2 Parallel connections Friday, 22 April 2011
  • 40. Parallel Downloads One domain = 2 Parallel connections HTML Image Image Image Image Image Image Image Image 0.4 0.8 1.2 1.6 2 2.4 Secs Friday, 22 April 2011
  • 41. Parallel Downloads Two domains = 4 Parallel connections HTML Image Image Image Image Image Image Image Image 0.4 0.8 1.2 1.6 2 2.4 Secs Friday, 22 April 2011
  • 42. Parallel Downloads Too many hostnames can cause complications Friday, 22 April 2011
  • 43. Parallel Downloads Too many hostnames can cause complications 2 – 4 sub domains is a good average Friday, 22 April 2011
  • 44. Combine Files Combining 6 scripts into 1 eliminates 5 requests Friday, 22 April 2011
  • 45. Combine Files Combining 6 scripts into 1 eliminates 5 requests Challenges: develop as separate modules combinations vs. loading more than needed Friday, 22 April 2011
  • 46. Javascript Doesn’t comply with parallel download rules Friday, 22 April 2011
  • 47. Javascript Doesn’t comply with parallel download rules HTML JS Image Image Image Image Image Image Image 0.4 0.8 1.2 1.6 2 2.4 Secs Friday, 22 April 2011
  • 48. Javascript script defer attribute is not a solution Friday, 22 April 2011
  • 49. Javascript script defer attribute is not a solution Solution - move them as low in the page as possible Friday, 22 April 2011
  • 52. Processing Fake the delivery Friday, 22 April 2011
  • 53. Processing Fake the delivery Lazy Loading Friday, 22 April 2011
  • 54. Processing Fake the delivery Lazy Loading Above the fold Loading Friday, 22 April 2011
  • 55. Processing Fake the delivery Lazy Loading Above the fold Loading Delay Javascript Loading Friday, 22 April 2011
  • 56. Processing http://www.appelsiini.net/projects/lazyload Friday, 22 April 2011
  • 57. Processing Bonus - async attribute http://www.appelsiini.net/projects/lazyload Friday, 22 April 2011
  • 59. JS Minification Crushes the file Strips out all cruft Voodoo Magic! Friday, 22 April 2011
  • 60. JS Minfication UglifyJS Google Closure YUI Compressor Dojo Shrinksafe JSMin Friday, 22 April 2011
  • 61. JS Minfication UglifyJS Google Closure YUI Compressor Dojo Shrinksafe JSMin http://bit.ly/compression-rates Friday, 22 April 2011
  • 62. CSS Minification YUI Compressor minifycss.com OOCSS Friday, 22 April 2011
  • 63. GZip GZip can be used on JS CSS XML JSON Friday, 22 April 2011
  • 64. GZip GZip should not be used on Images Document formats Already compressed Friday, 22 April 2011
  • 65. 404 robots.txt favicon Friday, 22 April 2011
  • 67. Images favicon Friday, 22 April 2011
  • 68. Images favicon CSS Sprites Friday, 22 April 2011
  • 69. Images favicon CSS Sprites Friday, 22 April 2011
  • 71. Sprites Reduces HTTP Requests Friday, 22 April 2011
  • 72. Sprites Reduces HTTP Requests Uses CSS Position magic Friday, 22 April 2011
  • 73. Sprites Reduces HTTP Requests Uses CSS Position magic Hard to maintain long term Friday, 22 April 2011
  • 74. Sprites Reduces HTTP Requests Uses CSS Position magic Hard to maintain long term Time sink Friday, 22 April 2011
  • 75. Sprites Reduces HTTP Requests Uses CSS Position magic Hard to maintain long term Time sink Too much magic Friday, 22 April 2011
  • 77. Resource Packages JAR file that contains everything Friday, 22 April 2011
  • 78. Resource Packages JAR file that contains everything Compresses Friday, 22 April 2011
  • 79. Resource Packages JAR file that contains everything Compresses Accesses individual resources Friday, 22 April 2011
  • 80. Resource Packages JAR file that contains everything Compresses Accesses individual resources Easy to maintain Friday, 22 April 2011
  • 81. Resource Packages JAR file that contains everything Compresses Accesses individual resources Easy to maintain New Proposal in the works Friday, 22 April 2011
  • 82. Images Badly optimised Thumbnails PNGs compressed up to 50% Friday, 22 April 2011
  • 83. PNG Optimise OptiPNG pngwolf pngcrush jpegtran Friday, 22 April 2011
  • 86. SSL Extra roundtrips Friday, 22 April 2011
  • 87. SSL Extra roundtrips More resources for servers Friday, 22 April 2011
  • 88. SSL Extra roundtrips More resources for servers Worth it, tho! Friday, 22 April 2011
  • 89. Tread the users’ path Test on slower connections Slow proxies Friday, 22 April 2011
  • 90. Tread the users’ path Tables / Phones Airline connections Public places Friday, 22 April 2011
  • 91. CDN Single domain Smart routing Data is closer to end user Friday, 22 April 2011
  • 94. CDN on a Budget S3 Friday, 22 April 2011
  • 95. Expires Headers Last-Modified Appropriate Dates Cache far in the future Change file names Friday, 22 April 2011
  • 96. ETags Hash Tag Cache vs Server More flexible than dates Good for Single Server Friday, 22 April 2011
  • 98. Problems Typically unique per server Friday, 22 April 2011
  • 99. Problems Typically unique per server Disable if not used Friday, 22 April 2011
  • 100. Farms Use options that are not unique per server Friday, 22 April 2011
  • 102. Reverse Proxies Varnish Nginx Squid Friday, 22 April 2011
  • 103. Query vs. Filename revisions Friday, 22 April 2011
  • 104. Query vs. Filename revisions Cache far in future Friday, 22 April 2011
  • 105. Query vs. Filename revisions Cache far in future Revisioning forces downloads Friday, 22 April 2011
  • 106. Query vs. Filename revisions Cache far in future Revisioning forces downloads Friday, 22 April 2011
  • 108. Query revisions Easy and convenient Friday, 22 April 2011
  • 109. Query revisions Easy and convenient Usually not recommended Friday, 22 April 2011
  • 110. Query revisions Easy and convenient Usually not recommended Bad proxies are a problem Friday, 22 April 2011
  • 112. Filename revisions Requires more work Friday, 22 April 2011
  • 113. Filename revisions Requires more work Recommended Friday, 22 April 2011
  • 114. Filename revisions Requires more work Recommended During build, using md5 hash Friday, 22 April 2011
  • 116. Compromise Create a version function Friday, 22 April 2011
  • 117. Compromise Create a version function Put on all resources Friday, 22 April 2011
  • 118. Compromise Create a version function Put on all resources mod_rewrite magic Friday, 22 April 2011
  • 119. Compromise Create a version function Put on all resources mod_rewrite magic http://bit.ly/query_rev_comp Friday, 22 April 2011
  • 120. Compromise Create a version function Put on all resources mod_rewrite magic http://bit.ly/query_rev_comp Friday, 22 April 2011
  • 122. Browser Tools Firebug Friday, 22 April 2011
  • 123. Browser Tools Firebug YSlow Friday, 22 April 2011
  • 124. Browser Tools Firebug YSlow PageSpeed Friday, 22 April 2011
  • 125. Browser Tools Firebug YSlow PageSpeed Chrome Inspector Friday, 22 April 2011
  • 126. Other Tools Friday, 22 April 2011
  • 127. Other Tools HTTPWatch.com Friday, 22 April 2011
  • 128. Other Tools HTTPWatch.com WebPageTest.org Friday, 22 April 2011
  • 129. Other Tools HTTPWatch.com WebPageTest.org HTTPArchive.org Friday, 22 April 2011
  • 130. Other Tools HTTPWatch.com WebPageTest.org HTTPArchive.org Yottaa.com Friday, 22 April 2011
  • 131. Other Tools HTTPWatch.com WebPageTest.org HTTPArchive.org Yottaa.com WonderProxy.com Friday, 22 April 2011
  • 132. Other Tools HTTPWatch.com WebPageTest.org HTTPArchive.org Yottaa.com WonderProxy.com pagespeed.googlelabs.com Friday, 22 April 2011
  • 133. Other Tools Friday, 22 April 2011
  • 134. Other Tools WonderProxy.com Friday, 22 April 2011
  • 135. Other Tools WonderProxy.com pagespeed.googlelabs.com Friday, 22 April 2011
  • 136. Other Tools WonderProxy.com pagespeed.googlelabs.com BrowserScope.com Friday, 22 April 2011
  • 137. Other Tools WonderProxy.com pagespeed.googlelabs.com BrowserScope.com html5boilerplate.com Friday, 22 April 2011
  • 139. Interesting Project Diffable Friday, 22 April 2011
  • 140. Interesting Project Diffable Uses deltas Friday, 22 April 2011
  • 141. Interesting Project Diffable Uses deltas Transfer only the diff Friday, 22 April 2011
  • 142. Interesting Project Diffable Uses deltas Transfer only the diff Can be used on JS and CSS Friday, 22 April 2011
  • 143. Interesting Project Diffable Uses deltas Transfer only the diff Can be used on JS and CSS http://code.google.com/p/diffable/ Friday, 22 April 2011
  • 144. “Knowledge rests not upon truth alone, but upon error also” - Carl G. Jung Friday, 22 April 2011
  • 145. Demo Time! Friday, 22 April 2011
  • 146. Questions? helgi@orchestra.io Twitter: @h Joind.in: http://joind.in/3340 Friday, 22 April 2011