This presentation discusses caching strategies for Magento websites. It covers using PHP accelerators like APC and Zend Optimizer+ to cache bytecode. It also discusses using Redis or Memcached for Magento cache/session handling instead of files or the database. The presentation recommends configuring a reverse proxy like Nginx or Varnish and using full page caches like Lesti::FPC or Zoom to cache entire pages. It also notes potential issues with full page caches and provides tips for optimizing caching.
2. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
About PHP accelerators
PHP is an interpreted language. The PHP interpreter converts PHP
to bytecode. A PHP engine can cache interpreted bytecode into
memory (or on the filesystem) by using a PHP accelerator (aka
opcode cacher).
3. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
PHP accelerators - listing
Zend Optimizer+
Built into PHP 5.5; Optional in PHP 5.4
APC
Standard opcode cacher under PHP 5.3 and PHP 5.4
Obsolete:
Xcache
eAccelerator
4. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
PHP accelerators - tips
Using Zend Optimizer+
PHP 5.5: Enabled by default
PHP 5.4: Perhaps faster than APC > benchmark for yourself
Using APC
Make sure APC cache is large enough
Make sure TTL is set and not 0
Set apc.stat = 0 if PHP-files don't change anymore
5. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
Magento cache / session handlers (1/2)
File (folder /var/cache)
Tip: Store in tmpfs / RAM-disk
Database
APC (Advanced PHP Cache)
or APCu (APC userland) under PHP 5.5)
6. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
Magento cache / session handlers (2/2)
memcached
Distributed caching system
Run through UNIX socket and not TCP/IP socket
Redis (recommended)
Dstributed caching system
Cm_RedisSession extension / Cm_Cache_Backend_Redis
Run through UNIX socket and not TCP/IP socket
7. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
Zend TwoLevel Cache
Fast cache backend
Options: APC, memcached, file
Slow cache backend
Options: Files, database, memcached, apc
Ment for management of tags, when fast cache does not
In practice
When memcached is used (fast cache), /var/cache is still used (slow cache)
When Redis is used (fast cache), /var/cache stays empty (no slow cache)
8. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
Magento caching - tips
Use Redis instead of memcache
Bypass Two Level Cache issue (and keep /var/cache empty)
Optimize “files” backend (/var/cache)
When small enough, use RAM disk or tmpfs
When larger, use Cm_Cache_Backend_File for more subfolders
When even larger, switch to other caching backend (preferred: Redis)
Larger cache
Beware of a cache being too large (>10Gb). Caching might become pointless.
9. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
Magento FPC (Full Page Cache)
Magento Enterprise Edition (Enterprise_PageCache)
Lesti::FPC
Free and very flexible
Make sure to configure Layered Navigation properly (especially sliders)
Zoom Full-Page Cache
Free and a bit faster than Lesti::FPC
No updates since Magento CE 1.8
AJAX calls for lazy loading
10. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
Issues with FPC
Cold cache is slow
Prewarm the cache by using site crawlers
Wrong content is displayed
Hole punching not configured properly
Make sure to check for proper caching of AJAX calls
Session data shared between customers
Only cache non-session specific data
Optionally use customer specific cache (Lesti: “lazy blocks”)
11. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
Reverse proxy
Nginx
Also native Nginx caching (fastcgi cache)
No hole punching, no cache purging
SSL support
Varnish
Magento extension Turpentine
Hole punching support via VCL (Varnish Control Language)
Cache purging via varnishadm (shell)
No SSL support
12. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
Yireo server configuration
Nginx / PHP-FPM
version 1.6: SPDY
FastCGI page caching
PHP-FPM through socket, not TCP/IP
PHP 5.4
Zend OPC, not APC
Magento + Redis cache
MySQL InnoDB tuning
13. Presentation “Magento Caching” - http://slideshare.net/yireo
Jisse Reitsma (jisse@yireo.com) - Twitter @yireo
Yireo Stuff
DisableLog
Disable all Magento logging
ProfilerLog
Gather profiling statistics over time (plus nice graphs in Magento backend)
Magento Performance Insights
Pending: Web-based in summer 2014