This document discusses using Varnish caching to speed up Magento websites. It explains how Varnish works by caching full page responses in memory and serving subsequent identical requests from the cache rather than Magento. This improves response times from 500ms-3s to under 100ms for cached pages. However, uncacheable pages like personalized or admin pages still require rendering by Magento. The document provides recommendations on extensions that integrate Magento and Varnish caching and warns it may not be suitable for all shops without custom configuration.
2. Who am I
• Maarten van Schaik
• Software developer at Byte Internet
• Creates tools for hosting Magento shops
3. The issue
• Magento is very extensive and complex
• There are a lot of extensions of varying
quality
• This can cause shops to become too slow
• Which impacts turnover
4. Possible solutions
• Better hardware
• Reduce number of extensions
• Don't use Magento! :-)
5. Normal request
GET /katten/kattenvoer
200 <html> ...
• User makes request
• Magento renders response
• Response time: 0.5 - 3 seconds
6. Request through Varnish
GET /katten/kattenvoer
GET /katten/kattenvoer
200 <html> ...
200 <html> ...
• User makes request
• Varnish passes request to Magento
• Varnish saves response in memory
• And serves it to the user
7. Next time: Varnish cache hit
GET /katten/kattenvoer
200 <html> ...
• Varnish has response in memory so can immediately
serve it to the user
• Response time: <100 ms
8. Uncacheable pages
GET /cart/checkout
GET /cart/checkout
Cache-control: no-cache
200 <html> ...
200 <html> ...
• Magento instructs Varnish to exclude certain URLs from
the cache
9. Personalized pages
POST /account/Loginpost
POST /account/Loginpost
Set-Cookie: LOGGED_IN
200 <html> ...
Set-Cookie: LOGGED_IN
200 <html> ...
• Once a user logs in it gets a cookie that indicates to
Varnish that requests have become
uncacheable
10. User views personalized pages
Cookie: LOGGED_IN
GET /katten/kattenvoer
Cookie: LOGGED_IN
GET /katten/kattenvoer
200 <html> ...
200 <html> ...
• As long as user has special cookie (logged in, stuff in
basket), Varnish will not cache
• Response time back to 0.5 - 3 seconds
11. Changing or removing catalog
GET /admin/delete/id/324
GET /admin/delete/id/324
Purge /katten/kattenvoer
Purge /katten
....
200 <html> ...
200 <html> ...
• Magento tells Varnish to purge
changed pages
12. So, what do I need?
• Avoid extensions that offer personalization
• Extension for Magento with matching
Varnish configuration file
http://connect20.magentocommerce.com/community/Varnish_Cache
http://connect20.magentocommerce.com/community/Made_Cache
https://github.com/fbrnc/Aoe_Static
https://github.com/nexcess/magento-turpentine
https://github.com/huguesalary/Magento-Varnish
13. Is Varnish caching for you?
• Not all shops are fit for full-page caching
• Will probably not work out of the box, so
knowledge on inner workings of Magento
might be needed
• Balance between personalized shopping
experience and caching
• Probably mostly useful for (very) large-scale
sites with high
concurrency