SHOW ME THE
PRESENTED TO THE 2017 ANN ARBOR WORDCAMP
BY ANDY MELICHAR
Who is this guy?
Director of
Web Development
at A2 Hosting
 We spend a lot of time on making
WordPress better for our customers!
 Ask me about Agile/Scrum!
 Ask me about Pair Programming!
Caveat Emptor!
 I am going to go through a lot of content
 I will go through it FAST
 There will be time for Q&A at the end
 I will also be around the rest of the afternoon for 1-
on-1 questions
Goals of this talk:
(in no particular order)
 Familiarize you with the different types of caching
and what they all do
 Explain the benefits of caching
 Look at some of the common plugins/tools used to
enable caching
 Point you towards some tools to help you conduct
performance testing
How many of you…
 Have attempted to optimize your WP Site?
 Have installed/configured a caching plugin?
 Know what a CDN is?
 Have added configurations to an .htaccess file
 Are running your own server (VPS/dedicated/cloud) ?
Some statistics…
 40% of people abandon a website that takes more
than 3 seconds to load
 A 1 second delay in page response can result in a 7%
reduction in conversions
 If an e-commerce site is making $100,000 per day, a
1 second page delay could potentially cost you $2.5
million in lost sales every year
Source: https://blog.kissmetrics.com/loading-time/
Bottom line…
 A poorly optimized website can cost you real $$ in
support and hosting costs
 By diving into performance and optimization, you’ll
learn more about WordPress, and more about web
systems and infrastructure
 Caching is one of the quickest, easiest ways you can
improve the performance of your WordPress site
How do you measure performance?
Performance Measurement Tools
 Gtmetrix.com – my favorite!
 Free
 Easy to use/understand
 Has a WordPress Plugin
 WebPageTest.org
 Also Free
 Lots of great detailed information
 LoadImpact.com
 Free + Paid plans
 Simulates multiple, concurrent users hitting your site
What Measurements Matter?
 Page Load Time
 Most representative of the customer experience
 Best “overall” performance metric
 Total Page Size
 Good to keep an eye on this for major problems such
as
Uncompressed images
High-resource themes/plugins
I shouldn’t have to say this, but…
 Clean house!
Get rid of unused themes/plugins/etc.
Don’t just deactivate… DELETE
Be sure everything is up-to-date
Most recent WordPress version
Plugins are all updated to latest version
What the heck is caching, anyway?
Cache [kash]
noun
Computers. a temporary storage space or memory that allows fast
access to data: Web browser cache; CPU cache.
An example of caching:
What is the answer?
x 17
24
8
2
16
042
804
1
Yay! We have an
answer…
BUT YOU SUFFER FROM SHORT-TERM MATH-MEMORY-LOSS…
AND YOU NEED TO SOLVE THIS MATH PROBLEM 10 TIMES A SECOND, 24 HOURS A DAY
What to do?
Add it to a solution cache
(a.k.a. a multiplication table)
22 23 24 25
15
16
17
18
408
Let’s apply this to
WordPress!
ACCESSING A WEB PAGE TAKES A LOT OF REPETITIVE WORK!
The Client/Server Process
WITHOUT Caching
The orange arrows repeat for every:
• Image
• CSS File
• JavaScript File
• Video
• Etc.
We can do better!
WITH CACHING!
Several Kinds of Caching Systems
Browser Cache
Page Cache
Object/Database Cache
Bytecode Cache
Content Delivery Network (CDN)
Browser Cache
 A local cache utilized by modern web
browsers, saves assets from websites so it
doesn’t have to re-download them on
subsequent page views
Pros/Cons of Browser Caching
 Browser cache relies on the client
 Short-term solution
 You have to configure WordPress to tell the
browser it CAN cache contents from your site
(we’ll get into that later)
Page Cache
 Takes an entire compiled page and saves it as
a file, so it doesn’t have to get compiled again.
?
?
Pros/Cons of Page Caching
 Usually file-system based (not stored in
memory) so still some overhead in disk I/O
 Stores the ENTIRE page
Problematic for truly dynamic content
Object Cache / Database Cache
 Stores the results of commonly-used queries
so the database doesn’t have to retrieve them
repeatedly
select * from wp_posts
select * from wp_posts ?
select * from wp_posts ?
Pros/Cons of Database/Object Caching
 DB access is high overhead, caching reduces
that overhead
 Stores data out of the database
Also problematic for dynamic content
Bytecode Cache
 Stores the compiled code (PHP) so the web
server doesn’t have to re-compile it at every
page load
 Is typically stored in memory for faster access
<?php
print "This is some PHP.";
?>
01011010100100100100101010
10101010010101011101010100
10101010101010101010101010
<html><body>This is some
PHP.</body></html>
?
?
Pros/Cons of Bytecode Caching
 Can be a little harder to enable
Especially if your host doesn’t support it
 May require a VPS/cloud/dedicated server
 Cache is stored in memory
(not disk) = FAST
Content Delivery Network (CDN)
 CDN Sits between the server and the client,
and handles serving up some/all of your files
 CDN’s typically have a large infrastructure of
multiple servers located in strategic
geographic locations
 Can also provide security / attack mitigation
The orange arrows repeat for every:
• Image
• CSS File
• JavaScript File
• Video
• Etc.
With a CDN
Things flow
differently!
With a CDN
Things flow
differently!
DDoS Attack
The traffic never
hits your server!
Pros/Cons of CDN
 Typically requires you to point your domain
DNS to the CDN service
 Can be frustrating if you don’t have sync set
up between your website and the CDN
properly
 Protects against DDoS and other attacks
JUST TELL ME HOW TO GET
CACHING!!
Ways to Enable Caching
 Plugins!
 Ask your host!
Common Caching Plugins
 WP Super Cache
 Recommended by WordPress
 Lots of features, not terrible to configure
 W3 Total Cache (or variants like Fix W3TC)
 Lots of features
 Can configure any which way under the sun
 WP Rocket
 Commercial
 “Set and forget” configuration
 WP Fastest Cache
 I don’t know much about this one but a lot of people like it
 Many, MANY others. YMMV.
Common Caching Plugins
WP Super Cache WP Rocket W3 Total Cache WP Fastest
Cost Free $39/single site Free, Premium
$99/year
Free, Premium
$39.99/lifetime
Browser Caching NO YES YES YES
Gzip YES YES YES YES
Minification NO YES YES YES
Page Caching YES YES YES YES
Database
Caching
NO NO YES NO
OpCache NO YES YES NO
CDN Support YES YES YES YES
Example Results – No Caching
Example Results – Caching
(WP Rocket)
Example Results – No Caching
Example Results – Caching
(WP Rocket)
Final Thoughts
 There are LOTS of options to optimize/gain
performance
 You don’t have to do them all
 Many people in the WordPress community
know how to help you with these
configurations
 The Codex is your friend!
Questions?
Contact Info:
@ANDYMELICHAR
ANDY@ANDYMELICHAR.COM

Show Me The Cache!

  • 1.
    SHOW ME THE PRESENTEDTO THE 2017 ANN ARBOR WORDCAMP BY ANDY MELICHAR
  • 2.
  • 3.
    Director of Web Development atA2 Hosting  We spend a lot of time on making WordPress better for our customers!  Ask me about Agile/Scrum!  Ask me about Pair Programming!
  • 4.
    Caveat Emptor!  Iam going to go through a lot of content  I will go through it FAST  There will be time for Q&A at the end  I will also be around the rest of the afternoon for 1- on-1 questions
  • 5.
    Goals of thistalk: (in no particular order)  Familiarize you with the different types of caching and what they all do  Explain the benefits of caching  Look at some of the common plugins/tools used to enable caching  Point you towards some tools to help you conduct performance testing
  • 6.
    How many ofyou…  Have attempted to optimize your WP Site?  Have installed/configured a caching plugin?  Know what a CDN is?  Have added configurations to an .htaccess file  Are running your own server (VPS/dedicated/cloud) ?
  • 7.
    Some statistics…  40%of people abandon a website that takes more than 3 seconds to load  A 1 second delay in page response can result in a 7% reduction in conversions  If an e-commerce site is making $100,000 per day, a 1 second page delay could potentially cost you $2.5 million in lost sales every year Source: https://blog.kissmetrics.com/loading-time/
  • 8.
    Bottom line…  Apoorly optimized website can cost you real $$ in support and hosting costs  By diving into performance and optimization, you’ll learn more about WordPress, and more about web systems and infrastructure  Caching is one of the quickest, easiest ways you can improve the performance of your WordPress site
  • 9.
    How do youmeasure performance?
  • 10.
    Performance Measurement Tools Gtmetrix.com – my favorite!  Free  Easy to use/understand  Has a WordPress Plugin  WebPageTest.org  Also Free  Lots of great detailed information  LoadImpact.com  Free + Paid plans  Simulates multiple, concurrent users hitting your site
  • 11.
    What Measurements Matter? Page Load Time  Most representative of the customer experience  Best “overall” performance metric  Total Page Size  Good to keep an eye on this for major problems such as Uncompressed images High-resource themes/plugins
  • 12.
    I shouldn’t haveto say this, but…  Clean house! Get rid of unused themes/plugins/etc. Don’t just deactivate… DELETE Be sure everything is up-to-date Most recent WordPress version Plugins are all updated to latest version
  • 13.
    What the heckis caching, anyway?
  • 14.
    Cache [kash] noun Computers. atemporary storage space or memory that allows fast access to data: Web browser cache; CPU cache.
  • 15.
    An example ofcaching: What is the answer? x 17 24 8 2 16 042 804 1
  • 16.
    Yay! We havean answer… BUT YOU SUFFER FROM SHORT-TERM MATH-MEMORY-LOSS… AND YOU NEED TO SOLVE THIS MATH PROBLEM 10 TIMES A SECOND, 24 HOURS A DAY
  • 17.
  • 18.
    Add it toa solution cache (a.k.a. a multiplication table) 22 23 24 25 15 16 17 18 408
  • 19.
    Let’s apply thisto WordPress! ACCESSING A WEB PAGE TAKES A LOT OF REPETITIVE WORK!
  • 20.
  • 21.
    The orange arrowsrepeat for every: • Image • CSS File • JavaScript File • Video • Etc.
  • 22.
    We can dobetter! WITH CACHING!
  • 23.
    Several Kinds ofCaching Systems Browser Cache Page Cache Object/Database Cache Bytecode Cache Content Delivery Network (CDN)
  • 24.
    Browser Cache  Alocal cache utilized by modern web browsers, saves assets from websites so it doesn’t have to re-download them on subsequent page views
  • 27.
    Pros/Cons of BrowserCaching  Browser cache relies on the client  Short-term solution  You have to configure WordPress to tell the browser it CAN cache contents from your site (we’ll get into that later)
  • 28.
    Page Cache  Takesan entire compiled page and saves it as a file, so it doesn’t have to get compiled again.
  • 30.
  • 31.
  • 32.
    Pros/Cons of PageCaching  Usually file-system based (not stored in memory) so still some overhead in disk I/O  Stores the ENTIRE page Problematic for truly dynamic content
  • 33.
    Object Cache /Database Cache  Stores the results of commonly-used queries so the database doesn’t have to retrieve them repeatedly
  • 34.
    select * fromwp_posts
  • 35.
    select * fromwp_posts ?
  • 36.
    select * fromwp_posts ?
  • 37.
    Pros/Cons of Database/ObjectCaching  DB access is high overhead, caching reduces that overhead  Stores data out of the database Also problematic for dynamic content
  • 38.
    Bytecode Cache  Storesthe compiled code (PHP) so the web server doesn’t have to re-compile it at every page load  Is typically stored in memory for faster access
  • 39.
    <?php print "This issome PHP."; ?> 01011010100100100100101010 10101010010101011101010100 10101010101010101010101010 <html><body>This is some PHP.</body></html>
  • 40.
  • 41.
  • 42.
    Pros/Cons of BytecodeCaching  Can be a little harder to enable Especially if your host doesn’t support it  May require a VPS/cloud/dedicated server  Cache is stored in memory (not disk) = FAST
  • 43.
    Content Delivery Network(CDN)  CDN Sits between the server and the client, and handles serving up some/all of your files  CDN’s typically have a large infrastructure of multiple servers located in strategic geographic locations  Can also provide security / attack mitigation
  • 44.
    The orange arrowsrepeat for every: • Image • CSS File • JavaScript File • Video • Etc.
  • 45.
    With a CDN Thingsflow differently!
  • 46.
    With a CDN Thingsflow differently!
  • 47.
    DDoS Attack The trafficnever hits your server!
  • 48.
    Pros/Cons of CDN Typically requires you to point your domain DNS to the CDN service  Can be frustrating if you don’t have sync set up between your website and the CDN properly  Protects against DDoS and other attacks
  • 50.
    JUST TELL MEHOW TO GET CACHING!!
  • 51.
    Ways to EnableCaching  Plugins!  Ask your host!
  • 52.
    Common Caching Plugins WP Super Cache  Recommended by WordPress  Lots of features, not terrible to configure  W3 Total Cache (or variants like Fix W3TC)  Lots of features  Can configure any which way under the sun  WP Rocket  Commercial  “Set and forget” configuration  WP Fastest Cache  I don’t know much about this one but a lot of people like it  Many, MANY others. YMMV.
  • 53.
    Common Caching Plugins WPSuper Cache WP Rocket W3 Total Cache WP Fastest Cost Free $39/single site Free, Premium $99/year Free, Premium $39.99/lifetime Browser Caching NO YES YES YES Gzip YES YES YES YES Minification NO YES YES YES Page Caching YES YES YES YES Database Caching NO NO YES NO OpCache NO YES YES NO CDN Support YES YES YES YES
  • 54.
  • 55.
    Example Results –Caching (WP Rocket)
  • 56.
  • 57.
    Example Results –Caching (WP Rocket)
  • 58.
    Final Thoughts  Thereare LOTS of options to optimize/gain performance  You don’t have to do them all  Many people in the WordPress community know how to help you with these configurations  The Codex is your friend!
  • 59.