2. Aaron Scherer
● Senior Software Engineer at
Underground Elephant
● Co-Organizer at San Diego PHP
● Founder of Seductive Turtle Inc.
● PHP Developer since 2007
○ Professionally since 2009
● http://www.aaronscherer.me
Core Developer of UECode and
GroupTopics
3. Types of Caching
● Opcode Cache
○ Compiles your code, speeds up execution
● Data/User Cache
○ Typical Key-Value storage
● Reverse Proxy Cache
○ Cache in between code and browser
● Browser Cache
○ Cache on the Browser
4. Opcode Cache
● Caches the bytecode of PHP. Can be stored
in Shared Memory for faster reads
● Increases speed by 2-7 times
● Popular Opcode Caches
○ APC - Was supposed to be put in core
○ Zend Optimizer+ - Being put in core (5.5)
■ https://wiki.php.net/rfc/optimizerplus
○ eAccelerator
○ XCache
○ HipHop - Weird, but awesome
5. Opcode Cache cont.
Most of these have to be installed by
compiling. You can find instructions on the
related project pages
Once they are installed, after some minor
configuration, you are done
6. Data/User Cache
● Cache user defined data with a key, for a
given lifetime
● Can significantly increase performance
○ Strong Hit/Miss ratio
● Memory Storage
● Popular Data Caches
○ APC - Very Fast, Not Distributed, Also Opcode
○ Memcached - Fast, Distributed, Awesome
○ Redis - Fast, Semi Distributed
7. Data/User Cache - APC
● Advantages
○ 4x+ faster than the other caches - No Network Calls
○ Also contains Opcode Cache
○ Easy
● Example
10. Gateway / Reverse Proxy Cache
● Varnish! (Most popular reverse proxy right
now)
● Shared cache across different clients
● Same thing as Browser
cache, except public
● ESI Tags
● A lot more...
11. Browser Cache
● Speed up load times for return visitors
● Help reduce load/network traffic on servers
● Same as reverse proxy, except private
● Used by setting HTML meta tags and
headers
● http://www.mnot.net/cache_docs/
● Can be done in PHP with "header()"
● Can be done in htaccess with
Expires and Headers
13. Conclusion
● Cache is important
● Pick the right cache for your needs
● https://wiki.php.net/rfc/optimizerplus
● http://www.mnot.net/cache_docs/
● http://phpmaster.com/an-introduction-to-redis-in-php-using-
predis/
Php is awesome
I'm awesome
I am the Iron Man, and the Batman