18
Site Caching From Nothing To Everything Site Caching, From Nothing To Everything Topher DeRosia @topher1kenobe

WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Embed Size (px)

DESCRIPTION

Discusses various methods of server side caching for WordPress.

Citation preview

Page 1: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Site CachingFrom Nothing To Everything

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Page 2: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Hi, my name is TopherI’m a WordPress developer from

Grand Rapids MI

@topher1kenobe

Site caching, from nothing to everythingTopher DeRosia, http://XWP.co

@topher1kenobe

http://XWP.co

Page 3: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Cache

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Synonyms:hoard, stockpile, reserve,store, stash

Bonus Homonym: Cash

Page 4: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Why Cache?

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

End User Speed

Server Health

SEO

Page 5: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

What are we fixing?

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Slow database queriesAnalyze with Query Monitor:https://wordpress.org/plugins/query-monitor/

Large, uncompressed files

Inefficient software

Page 6: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

What does caching do?

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

It saves a plain html version of a WordPress generated page.

It then serves that plain html version instead of letting WordPress do all that work again.

This is MUCH faster.

Page 7: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Step 1, cache all the things!

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

WP Super Cachehttps://wordpress.org/plugins/wp-super-cache/

W3 Total Cachehttps://wordpress.org/plugins/w3-total-cache/

Batcachehttps://wordpress.org/plugins/batcache/

WP Rockethttp://wp-rocket.me/

Page 8: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Gee, zipping is cool!

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Gzip is a compression program. Good caching plugins allow you to gzip your cached page.

On topher1kenobe.com:

Page 9: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Watch out for SEO plugins!

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

They’re greedy, and flush the cache too often.

On high traffic sites it can be more than once per second.

Page 10: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Step 2, Efficient web servers

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Apache: powerful, awesome, SLOW

Nginx: fewer features, similar to Apache for dynamic content, FAST serving static content

Page 11: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Step 2a, reverse proxy

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Use Apache to serve dynamic pages, Nginx or Varnish to serve static pages

Page 12: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Step 3, Speedy PHP Parser

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

mod_php: Apache module. Fast enough.

php-fcgi: quite fast, very common

php-fpm: VERY fast, awesome.

hhvm: blindingly fast, can be buggy

Page 13: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Step 4, memcache

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Generic data storage in RAM. Super fast.

IMPORTANT: permanently borrows system RAM. Don’t take too much.

Page 14: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Step 5, OpCode Cache

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Stores compiled PHP in RAM, causing the app itself to be faster.

APC (Alternative PHP Cache)XCacheZend OpCache

Use what your sysadmin is comfortable with

https://en.wikipedia.org/wiki/List_of_PHP_accelerators

Page 15: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Step 6, Fragment caching

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Full page caching usually isn’t much help for people who are logged in.

1. You2. Subscribers3. Community members (BuddyPress, bbPress)4. Content managers

Page 16: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Transients

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Fragments of data you can store in a cache with PHP.

http://codex.wordpress.org/Transients_API

Results of complex queriesResults of remote data calls

Page 17: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

Finding Slow Spots

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

Several different plugins can help find slow spots:

Query Monitorhttps://wordpress.org/plugins/query-monitor/

Debug Bar ( many addons )https://wordpress.org/plugins/debug-bar/

Page 18: WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything

THANKS FOR

LISTENING

Site Caching, From Nothing To EverythingTopher DeRosia

@topher1kenobe

http://topher1kenobe.comFollow me @topher1kenobe