Slide 1

Slide 1 text

Meet Magento Poland 2014 Meet Magento Poland 2014 Marko Martinović Magento 2 Caching Strategies

Slide 2

Slide 2 text

Meet Magento Poland 2014 2.0 Platform Goals “Improved performance and scalability”

Slide 3

Slide 3 text

Meet Magento Poland 2014 Architecture Built on top of Zend_Cache

Slide 4

Slide 4 text

Meet Magento Poland 2014 Architecture Multiple frontend pools, each associated to one or two level backend adapter

Slide 5

Slide 5 text

Meet Magento Poland 2014 Architecture Each cache type with its own class enforcing specific cache tag

Slide 6

Slide 6 text

Meet Magento Poland 2014 Frontend Pools Out the box: • default - General type instances • page_cache - PageCache type instance

Slide 7

Slide 7 text

Meet Magento Poland 2014 Backend Adapters Cm_Cache_Backend_File as the default cache backend

Slide 8

Slide 8 text

Meet Magento Poland 2014 Backend Adapters All the usual suspects, with MongoDB adapter introduced

Slide 9

Slide 9 text

Meet Magento Poland 2014 Cache Types Good old ● Configuration ● Layouts ● Blocks HTML output ● Collections data ● EAV types and attributes ● Translations Brand New ● View files fallback ● View files pre- processing ● Integrations Configuration ● Integrations API Configuration ● Web Services Configuration ● PageCache

Slide 10

Slide 10 text

Meet Magento Poland 2014 Collections Data Fetch strategy interface with Query and Cache implementations

Slide 11

Slide 11 text

Meet Magento Poland 2014 Collections Data Store, Store Group, Website and Catalog Category collection cached

Slide 12

Slide 12 text

Meet Magento Poland 2014 EAV Types and Attributes Implemented to cache eav_entity_type table collection. Still here, still unused, still no one knows why.

Slide 13

Slide 13 text

Meet Magento Poland 2014 EAV Types and Attributes "One developer is working on it for a month, other comments it out for testing, third one is then afraid to enable it back" -Ivan Weiler @Inchoo

Slide 14

Slide 14 text

Meet Magento Poland 2014 View Files Fallback Requested asset is being searched for using fallback rules applied to fallback context

Slide 15

Slide 15 text

Meet Magento Poland 2014 View Files Fallback Path to requested asset resolved and cached

Slide 16

Slide 16 text

Meet Magento Poland 2014 View Files Pre-processing Pre-processing of Magento-flavoured CSS tricks like @magento_import, @import, scope notation file references and Less

Slide 17

Slide 17 text

Meet Magento Poland 2014 View Files Pre-processing Path to pre-processed asset cached

Slide 18

Slide 18 text

Meet Magento Poland 2014 PageCache Out the box: • PHP/AJAX based (Built-in) • Reverse proxy/ESI/AJAX based (Varnish)

Slide 19

Slide 19 text

Meet Magento Poland 2014 PageCache Caching controlled by ‘Cache-Control’: public, max-age=XY, s-maxage=XY vs. private, max-age=YZ vs. no-store, no-cache, must-revalidate, max- age=0

Slide 20

Slide 20 text

Meet Magento Poland 2014 PageCache Setting cacheable=false to some block results with whole page not being cached

Slide 21

Slide 21 text

Meet Magento Poland 2014 Hole Punching Setting _isScopePrivate to some block results with its content not being cached

Slide 22

Slide 22 text

Meet Magento Poland 2014 Hole Punching Setting ttl to some block results with its content being served through ESI and cached by Varnish

Slide 23

Slide 23 text

Meet Magento Poland 2014 Built-in Page cache saved through dedicated frontend instance by PHP code

Slide 24

Slide 24 text

Meet Magento Poland 2014 Built-in Dynamic blocks not cached and served exclusively through AJAX:
  • Default welcome msg!
  • Slide 25

    Slide 25 text

    Meet Magento Poland 2014 Built-in Pros ● Works out the box with no special setup Cons ● Leaves a lot to be desired performance- wise

    Slide 26

    Slide 26 text

    Meet Magento Poland 2014 Varnish

    Slide 27

    Slide 27 text

    Meet Magento Poland 2014 Varnish Page cache maintained and served by reverse proxy

    Slide 28

    Slide 28 text

    Meet Magento Poland 2014 Varnish Without ttl set, dynamic blocks not cached and served through AJAX

    Slide 29

    Slide 29 text

    Meet Magento Poland 2014 Varnish With ttl set, dynamic blocks cached and served through ESI:

    Slide 30

    Slide 30 text

    Meet Magento Poland 2014 Varnish Pros ● The best performing caching solution, if properly configured Cons ● The worst performing caching solution, if configured improperly ● Considerable setup and maintenance overhead ● Requires SSL termination proxy to support HTTPS

    Slide 31

    Slide 31 text

    Meet Magento Poland 2014 Benchmarks Magento 2 (Alpha 102) Magento EE (1.14.0.1)

    Slide 32

    Slide 32 text

    Meet Magento Poland 2014 Any questions?

    Slide 33

    Slide 33 text

    Meet Magento Poland 2014 @MarkoTechyTalk Team Lead/MCD+ at Inchoo Thank you!