Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

WordCamp Bratislava 2019 - Cache!

279 views

Published on

Různé možnosti cachování ve WordPress - cache v prohlížeči, cachovací pluginy, object cache, OP code cache, cachování lokalizací a další triky.

Published in: Technology
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Copas Url to Read eBook === http://zakuratest.com/B005P790DG-La-Face-cache-du-temps--Limaginaire-de-laudel-Essais.html
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

WordCamp Bratislava 2019 - Cache!

  1. 1. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Cache! To chceš! Vláďa Smitka vladimir.smitka@lynt.cz @smitka Lynt services s.r.o.
  2. 2. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba1912. 10. 2019 2
  3. 3. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba1912. 10. 2019 3 Co je cache? Výkon – nemusím znova dělat náročné operace Aktuálnost – musím řešit neplatná data (invalidace) + -
  4. 4. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba1912. 10. 2019 4 Cachování OP code cache Transientní cache Stránková cache Cache prohlížeče Objektová cache Disková cache Proxy cache
  5. 5. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Cache prohlížeče <IfModule mod_expires.c> <FilesMatch ".(?i:gif|jpe?g|png|js|css|ico|woff|svg)$"> ExpiresActive on ExpiresDefault "access plus 365 days" </Filesmatch> </IfModule> 12. 10. 2019 5
  6. 6. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Co, když nemám Expires hlavičky? • Heuristika prohlížeče • (teď – datum poslední modifikace)/10 • https://tools.ietf.org/html/rfc7234#section-4.2.2 12. 10. 2019 6
  7. 7. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Proxy cache • Na vstupu do vaší sítě (už se moc nepoužívá kvůli HTTPS) • Na cestě – např. CloudFlare • Před serverem – Varnish, Nginx 12. 10. 2019 7
  8. 8. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 CloudFlare • Pomůže mi? 12. 10. 2019 8
  9. 9. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Debug problémů se zdroji • https://www.webpagetest.org • https://gtmetrix.com/ • https://redbot.org/ 12. 10. 2019 9
  10. 10. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Plně stránková cache • Cachovací plugin –WP SuperCache –… W3, Comet, Fastest… –WP Rocket 12. 10. 2019 10
  11. 11. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Jak fungují cachovací pluginy? • Princip – uložit vypočítanou PHP stránku jako statické HTML na disk (output buffer) • Přístup: – Test z .htaccess, zda soubor cache existuje – Malý PHP skript (větší kontrola, pomalejší) • Zlepšováky 12. 10. 2019 11
  12. 12. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 WP Rocket 12. 10. 2019 12
  13. 13. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 WP SuperCache 12. 10. 2019 13
  14. 14. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Pod pokličkou WP SuperCache RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{QUERY_STRING} !.*=.* RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$ RewriteCond %{HTTPS} on RewriteCond %{DOCUMENT_ROOT}/wpc/cache/supercache/%{SERVER_NAME}/$1/index-https.html -f RewriteRule ^(.*) "/wpc/cache/supercache/%{SERVER_NAME}/$1/index-https.html" [L] cache └── supercache ├── index.html └── testweb.xy ├── index-https.html └── wordcamp-bratislava └── index-https.html 12. 10. 2019 14 https://testweb.xy/wordcamp-bratislava/
  15. 15. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Bez cache 12. 10. 2019 15
  16. 16. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 WP SuperCache - PHP 12. 10. 2019 16
  17. 17. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 WP SuperCache - server 12. 10. 2019 17
  18. 18. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Nginx Microcache 12. 10. 2019 18
  19. 19. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Kdy se necachuje? • https://2019.bratislava.wordcamp.org/?a=1 • https://2019.bratislava.wordcamp.org/?fbclid=ABCD1234 • https://2019.bratislava.wordcamp.org/?gclid=ABCD1234 • https://2019.bratislava.wordcamp.org/?utm_medium=email 12. 10. 2019 19 Fix: interní přesměrování pro nemodifikující parametry https://gist.github.com/lynt-smitka/297004bed3aa4fb3065af16fd6e7ff18 WP Rocket má výjimky pro běžné nemodifikující parametry Parametry často dělají problém při přesměrování, tester: https://www.ppc-robot.net/cs/autotagging-tester/
  20. 20. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Kdy je špatné cachovat? • Dynamické stránky – Přihlášení uživatelé (většinou) – Web s košíkem – Web s uživatelem nastavitelnými parametry (filtry) • Formuláře – Je zde nonce (platnost 12-24 hodin) – Bezpečná doba cachování 10 hodin 12. 10. 2019 20
  21. 21. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 „Na e-shopech cachovací pluginy moc nefungují“ 12. 10. 2019 21
  22. 22. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Objektová cache • WP z dat v databázi skládá objekty, se kterými dále pracuje – náročná operace, mnoho dotazů do DB • Některé lze uložit lokálně 127.0.0.1:6379> keys *:1929 1) "wp_:post_tag_relationships:1929" 2) "wp_:category_relationships:1929" 3) "wp_:posts:1929" 4) "wp_:post_format_relationships:1929" 5) "wp_:post_meta:1929" 12. 10. 2019 22
  23. 23. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Objektová cache • Server musí podporovat uložiště • WordPress má podporu, je ji potřeba aktivovat podle použitého úložiště • Drop-in do WP (Memcache, Redis, Xcache, APCu) • Není to běžné na sdílených hostinzích • Výpočetně náročná serializace • Ne všechny pluginy a šablony s ní počítají – složitější invalidace 12. 10. 2019 23
  24. 24. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Serializace 12. 10. 2019 24 a:13:{s:7:"vajicka";i:4;s:15:"krupicovy cukor";s:4:"125g";s:15:"vanilkovy cukor";i:1;s:5:"maslo";s:4:"125g";s:6:"mlieko";s:4:"50ml";s:14:"muka polohruba";s:5:"150g";s:5:"kakao";s:3:"50g";s:16:"prasok do peciva";i:1;s:10:"mascarpone";s:4:"250g";s:18:"slahackova smotana";s:4:"250g";s:12:"jemny tvaroh";s:4:"250g";s:8:"cokolada";s:3:"50g";s:5:"banan";i:3;}
  25. 25. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Redukce DB dotazů 12. 10. 2019 25 Může být kontraproduktivní, pokud web dělá několik stovek dotazů do DB – náročná serializace!
  26. 26. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Transientní cache • WP v základu může ukládat výsledky mnoha složitých operací do databáze • _site_transient_* a _transient_* ve wp- options • Pokud je k dispozici objektová cache, může být využita místo DB • https://codex.wordpress.org/Transients_API 12. 10. 2019 26
  27. 27. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 OP cache • Kompiluje PHP zdroják • Vyšší verze PHP s ní umí lépe pracovat • Spotřebovává více RAM • Běžný WP kolem 20MB • opcache.memory_consumption • opcache.revalidate_freq • https://github.com/rlerdorf/opcache-status (starý, ale dobrý) • https://github.com/amnuts/opcache-gui • https://github.com/PeeHaa/OpCacheGUI 12. 10. 2019 27
  28. 28. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba1912. 10. 2019 28
  29. 29. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Disková cache 12. 10. 2019 29 RAM není nikdy dost – Linux ji využije!
  30. 30. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Co dále cachovat? • Cache lokalizací – https://github.com/lynt-smitka/WP-nginx- config/blob/master/extras/mu-plugins/ – lynt-mo-cache.php – lynt-mo-cache-igb.php • Cache widgetů a menu 12. 10. 2019 30
  31. 31. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba1912. 10. 2019 31 Bez OP cache Zapnutá OP cache (standard, nezaplněná) – méně RAM, protože soubory jsou v OP cache Cache lokalizací – PHP třídy – ještě méně RAM, protože i lokalizace jsou v OP cache Cache lokalizací – igbinary – rychlejší, více RAM, protože se načítají binární soubory Cache lokalizací igb + Object cache v OP cache – méně dotazů bez serializace
  32. 32. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Objektová cache II. • Není to běžné na sdílených hostinzích • Výpočetně náročná serializace • https://github.com/elcobvg/wordpress- opcache 12. 10. 2019 32 cache ├── wp-opcache-001750be6fac24fa5b1d57b91ffd44d7.php ├── wp-opcache-03e1fcb75c96dd27d0c18d7fbc528c2d.php ├── wp-opcache-073d1cde8e952fea0fc9ec449ecef86e.php ├── wp-opcache-089b61a0516793ff0c3f638785900d0a.php │… <?php return array(9999999999,(object) array( 'ID' => '1', 'post_author' => '1', 'post_date' => '2019-08-08 06:19:00', 'post_date_gmt' => '2019-08-08 06:19:00', 'post_content' => '...', 'post_title' => 'Hello world!', … 'post_type' => 'post', 'post_mime_type' => '', 'comment_count' => '1', ));
  33. 33. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Jak ladit bez profileru? • Query monitor • https://wordpress.org/plugins/query-monitor/ 12. 10. 2019 33
  34. 34. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba19 Co si odnést? • Expires hlavičky – vždy • CloudFlare – pro větší návštěvnost nebo geo • Cache lokalizací – dobrý přínos a minimum side efektů • Prezentační weby/blogy – cachovací plugin (pozor na nonce) • Pozor na parametry v URL! • E-shopy – nutné řešit od základu, je třeba zrušit špatné komponenty, Object Cache může někdy pomoci • Je dobré zkontrolovat využívání OP Cache • Při nákupu VPS/Dediku koupit rovnou více RAM • Query Monitor pro ladění 12. 10. 2019 34
  35. 35. https://lynt.cz @smitka Odkazy: https://u.lynt.cz/wcba1912. 10. 2019 35 A to je vše, přátelé.

×