SlideShare une entreprise Scribd logo
1  sur  13
Télécharger pour lire hors ligne
Caching in WordPress 
Tareq Hasan (@tareq_cse) 
http://tareq.weDevs.com
What is Caching? 
• Serve static content to the visitor without querying 
the database. 
• Not generated upon **every** request 
• Reduce to API calls
Type of Caching? 
• Page Cache - Whole page as static content 
• Query Cache - Cache SQL query results 
• Fragment Cache - Cache a piece of page 
• Browser Cache - Cache page assets 
• Opcode Cache - PHP executes faster
WordPress Caching APIs 
Transients! 
- Persistent out of the box 
- Stored in wp_options 
get_transient() 
set_transient() 
delete_transient() 
Object Cache! 
- Not persistent without a 
persistent backend 
- Storage depends on the 
backend 
wp_cache_add() 
wp_cache_set() 
wp_cache_get() 
wp_cache_delete()
Using Transients 
set_transient( $key, $value, $expiration ); 
<?php 
// Get any existing copy of our transient data 
$special_query = get_transient( 'special_query' ); 
if ( false === $special_query_results ) { 
$special_query = new WP_Query( 'cat=5&order=random' ); 
set_transient( 'special_query', $special_query, 12 * HOUR_IN_SECONDS ); 
} 
// Use the data like you would have normally... 
Queries only after each 12 hours
Object Cache 
• Not persistent. Means, valid for only one pageload 
• Requires a persistent backend. Such as APC, 
Memcached. 
• Plugins like W3 Total Cache, Memcached Object 
Cache helps. 
• Used Extensively in WordPress 
• Cache objects can be grouped
Object Cache Functions 
// set the cache with value 
wp_cache_add( $key, $data, $group, $expire ) 
wp_cache_set( $key, $data, $group, $expire ) 
// retrieve the value from cache 
wp_cache_get( $key, $group ) 
// clears data from the cache for the given key. 
wp_cache_replace( $key, $data, $group, $expire ) 
// clears all cached data. 
wp_cache_flush()
Using Object Cache 
$result = wp_cache_get( 'my_result' ); 
if ( false === $result ) { 
$result = $wpdb->get_results( $query ); 
wp_cache_set( 'my_result', $result ); 
} 
// Do something with $result; 
http://codex.wordpress.org/Class_Reference/WP_Object_Cache
Persistent Cache Plugins 
• W3 Total Cache 
• WP File Cache 
• Memcached Object Cache 
• APC Object Cache 
• WordPress Redis Backend
Fragment Caching 
• Cache a fragment of a page 
• This could be your menubar, widgets and other 
query related parts. 
https://gist.github.com/markjaquith/2653957
Browser Caching 
• HTTP Cache-Control 
• Expiry Headers 
• Entity Tags 
(W3-Total-Cache, WP Super Cache) 
http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/
Opcode Cache 
php-apc + W3 Total Cache
Questions?

Contenu connexe

Tendances

Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeAJ Morris
 
Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress WayMatt Wiebe
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPresstopher1kenobe
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...andrewnacin
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockCaldera Labs
 
Entry-level PHP for WordPress
Entry-level PHP for WordPressEntry-level PHP for WordPress
Entry-level PHP for WordPresssprclldr
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011andrewnacin
 
Integrating External APIs with WordPress
Integrating External APIs with WordPressIntegrating External APIs with WordPress
Integrating External APIs with WordPressMarty Thornley
 
Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium Workhorse Computing
 
WordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressWordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressandrewnacin
 
Htaccess file tutorial and tips
Htaccess file tutorial and tipsHtaccess file tutorial and tips
Htaccess file tutorial and tipsImam Rosidi
 
Integrating WordPress With Web APIs
Integrating WordPress With Web APIsIntegrating WordPress With Web APIs
Integrating WordPress With Web APIsrandyhoyt
 
Technical SEO: .htaccess & 301 Redirects
Technical SEO:  .htaccess & 301 RedirectsTechnical SEO:  .htaccess & 301 Redirects
Technical SEO: .htaccess & 301 RedirectsRob Bertholf
 

Tendances (20)

Php basics
Php basicsPhp basics
Php basics
 
Drupal Multi-site for Fun and Profit
Drupal Multi-site for Fun and ProfitDrupal Multi-site for Fun and Profit
Drupal Multi-site for Fun and Profit
 
Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your life
 
Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress Way
 
Php workshop L04 database
Php workshop L04 databasePhp workshop L04 database
Php workshop L04 database
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPress
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
 
Php workshop L03 superglobals
Php workshop L03 superglobalsPhp workshop L03 superglobals
Php workshop L03 superglobals
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
 
Entry-level PHP for WordPress
Entry-level PHP for WordPressEntry-level PHP for WordPress
Entry-level PHP for WordPress
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011
 
Integrating External APIs with WordPress
Integrating External APIs with WordPressIntegrating External APIs with WordPress
Integrating External APIs with WordPress
 
Selenium sandwich-2
Selenium sandwich-2Selenium sandwich-2
Selenium sandwich-2
 
Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium
 
WordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressWordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPress
 
Htaccess file tutorial and tips
Htaccess file tutorial and tipsHtaccess file tutorial and tips
Htaccess file tutorial and tips
 
Integrating WordPress With Web APIs
Integrating WordPress With Web APIsIntegrating WordPress With Web APIs
Integrating WordPress With Web APIs
 
Week3 adb
Week3 adbWeek3 adb
Week3 adb
 
Technical SEO: .htaccess & 301 Redirects
Technical SEO:  .htaccess & 301 RedirectsTechnical SEO:  .htaccess & 301 Redirects
Technical SEO: .htaccess & 301 Redirects
 
Ithemes presentation
Ithemes presentationIthemes presentation
Ithemes presentation
 

En vedette

Intro to advanced caching in WordPress
Intro to advanced caching in WordPressIntro to advanced caching in WordPress
Intro to advanced caching in WordPressMaor Chasen
 
EXPERIENCIA EN LA IMPLEMENTACIÓN DE LA VUCE COLOMBIA
EXPERIENCIA EN LA IMPLEMENTACIÓN DE LA VUCE COLOMBIAEXPERIENCIA EN LA IMPLEMENTACIÓN DE LA VUCE COLOMBIA
EXPERIENCIA EN LA IMPLEMENTACIÓN DE LA VUCE COLOMBIACADEX SCZ
 
Planificacion de Proyectos Civiles
Planificacion de Proyectos CivilesPlanificacion de Proyectos Civiles
Planificacion de Proyectos Civilesilaycolina
 
PAA 2016 Musical Theatre Flyer
PAA 2016 Musical Theatre FlyerPAA 2016 Musical Theatre Flyer
PAA 2016 Musical Theatre FlyerFrancesca Denton
 
Forrester research report
Forrester research reportForrester research report
Forrester research reportnwyne
 
Risk Ecosystem Survey Infographic
Risk Ecosystem Survey InfographicRisk Ecosystem Survey Infographic
Risk Ecosystem Survey InfographicBooz Allen Hamilton
 
Issue desk slides summer 11
Issue desk slides summer 11Issue desk slides summer 11
Issue desk slides summer 11uclmainlibrary
 
Mliven AlsoMobile.com
Mliven AlsoMobile.comMliven AlsoMobile.com
Mliven AlsoMobile.comJan Rezab
 
زندگی پس از زندگی
زندگی پس از زندگیزندگی پس از زندگی
زندگی پس از زندگیkourosh
 
Propuesta curricular-baja
Propuesta curricular-bajaPropuesta curricular-baja
Propuesta curricular-bajaPablo Cortez
 
Terminologia arancelaria
Terminologia arancelariaTerminologia arancelaria
Terminologia arancelariaKeivan Dlr
 
Public Opinion Landscape: Election 2016
Public Opinion Landscape: Election 2016Public Opinion Landscape: Election 2016
Public Opinion Landscape: Election 2016GloverParkGroup
 
Le mobile en passe de devenir un device médical
Le mobile en passe de devenir un device médicalLe mobile en passe de devenir un device médical
Le mobile en passe de devenir un device médicalVEZIN Fabrice
 
La Formazione e l’aggiornamento professionale dei docenti in eTwinning e co...
La Formazione e l’aggiornamento professionale dei docenti  in  eTwinning e co...La Formazione e l’aggiornamento professionale dei docenti  in  eTwinning e co...
La Formazione e l’aggiornamento professionale dei docenti in eTwinning e co...sefralt
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm designNahid Hasan
 
Sistema de inspección, regulaciones y procedimientos para la importación de f...
Sistema de inspección, regulaciones y procedimientos para la importación de f...Sistema de inspección, regulaciones y procedimientos para la importación de f...
Sistema de inspección, regulaciones y procedimientos para la importación de f...ProColombia
 

En vedette (20)

Intro to advanced caching in WordPress
Intro to advanced caching in WordPressIntro to advanced caching in WordPress
Intro to advanced caching in WordPress
 
La empresa y el mercado
La empresa y el mercadoLa empresa y el mercado
La empresa y el mercado
 
EXPERIENCIA EN LA IMPLEMENTACIÓN DE LA VUCE COLOMBIA
EXPERIENCIA EN LA IMPLEMENTACIÓN DE LA VUCE COLOMBIAEXPERIENCIA EN LA IMPLEMENTACIÓN DE LA VUCE COLOMBIA
EXPERIENCIA EN LA IMPLEMENTACIÓN DE LA VUCE COLOMBIA
 
Planificacion de Proyectos Civiles
Planificacion de Proyectos CivilesPlanificacion de Proyectos Civiles
Planificacion de Proyectos Civiles
 
PAA 2016 Musical Theatre Flyer
PAA 2016 Musical Theatre FlyerPAA 2016 Musical Theatre Flyer
PAA 2016 Musical Theatre Flyer
 
Forrester research report
Forrester research reportForrester research report
Forrester research report
 
Risk Ecosystem Survey Infographic
Risk Ecosystem Survey InfographicRisk Ecosystem Survey Infographic
Risk Ecosystem Survey Infographic
 
Issue desk slides summer 11
Issue desk slides summer 11Issue desk slides summer 11
Issue desk slides summer 11
 
Mliven AlsoMobile.com
Mliven AlsoMobile.comMliven AlsoMobile.com
Mliven AlsoMobile.com
 
زندگی پس از زندگی
زندگی پس از زندگیزندگی پس از زندگی
زندگی پس از زندگی
 
Propuesta curricular-baja
Propuesta curricular-bajaPropuesta curricular-baja
Propuesta curricular-baja
 
Muse Score
Muse ScoreMuse Score
Muse Score
 
Trable programatora
Trable programatoraTrable programatora
Trable programatora
 
Terminologia arancelaria
Terminologia arancelariaTerminologia arancelaria
Terminologia arancelaria
 
Public Opinion Landscape: Election 2016
Public Opinion Landscape: Election 2016Public Opinion Landscape: Election 2016
Public Opinion Landscape: Election 2016
 
Le mobile en passe de devenir un device médical
Le mobile en passe de devenir un device médicalLe mobile en passe de devenir un device médical
Le mobile en passe de devenir un device médical
 
Salesforce for B2C
Salesforce for B2CSalesforce for B2C
Salesforce for B2C
 
La Formazione e l’aggiornamento professionale dei docenti in eTwinning e co...
La Formazione e l’aggiornamento professionale dei docenti  in  eTwinning e co...La Formazione e l’aggiornamento professionale dei docenti  in  eTwinning e co...
La Formazione e l’aggiornamento professionale dei docenti in eTwinning e co...
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm design
 
Sistema de inspección, regulaciones y procedimientos para la importación de f...
Sistema de inspección, regulaciones y procedimientos para la importación de f...Sistema de inspección, regulaciones y procedimientos para la importación de f...
Sistema de inspección, regulaciones y procedimientos para la importación de f...
 

Similaire à Caching in WordPress

Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingErick Hitter
 
Consuming & embedding external content in WordPress
Consuming & embedding external content in WordPressConsuming & embedding external content in WordPress
Consuming & embedding external content in WordPressAkshay Raje
 
WordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkWordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkExove
 
MUC - Moodle Universal Cache
MUC - Moodle Universal CacheMUC - Moodle Universal Cache
MUC - Moodle Universal CacheTim Hunt
 
eZ Publish Cluster Unleashed
eZ Publish Cluster UnleashedeZ Publish Cluster Unleashed
eZ Publish Cluster UnleashedBertrand Dunogier
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Kris Wallsmith
 
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...Codemotion
 
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...Codemotion
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordCamp Kyiv
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliGetSource
 
Dutch php conference_apc_mem2010
Dutch php conference_apc_mem2010Dutch php conference_apc_mem2010
Dutch php conference_apc_mem2010isnull
 
Transients are good for you - WordCamp London 2016
Transients are good for you - WordCamp London 2016Transients are good for you - WordCamp London 2016
Transients are good for you - WordCamp London 2016Boiteaweb
 
HTTP Caching and PHP
HTTP Caching and PHPHTTP Caching and PHP
HTTP Caching and PHPDavid de Boer
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliGetSource
 
Built-in query caching for all PHP MySQL extensions/APIs
Built-in query caching for all PHP MySQL extensions/APIsBuilt-in query caching for all PHP MySQL extensions/APIs
Built-in query caching for all PHP MySQL extensions/APIsUlf Wendel
 
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Cliff Seal
 
How Not to Build a WordPress Plugin
How Not to Build a WordPress PluginHow Not to Build a WordPress Plugin
How Not to Build a WordPress PluginWill Norris
 
Windows Azure Storage & Sql Azure
Windows Azure Storage & Sql AzureWindows Azure Storage & Sql Azure
Windows Azure Storage & Sql AzureMaarten Balliauw
 

Similaire à Caching in WordPress (20)

Caching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment CachingCaching and Scaling WordPress using Fragment Caching
Caching and Scaling WordPress using Fragment Caching
 
Consuming & embedding external content in WordPress
Consuming & embedding external content in WordPressConsuming & embedding external content in WordPress
Consuming & embedding external content in WordPress
 
WordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkWordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a Framework
 
MUC - Moodle Universal Cache
MUC - Moodle Universal CacheMUC - Moodle Universal Cache
MUC - Moodle Universal Cache
 
eZ Publish Cluster Unleashed
eZ Publish Cluster UnleashedeZ Publish Cluster Unleashed
eZ Publish Cluster Unleashed
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
 
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
 
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cli
 
Dutch php conference_apc_mem2010
Dutch php conference_apc_mem2010Dutch php conference_apc_mem2010
Dutch php conference_apc_mem2010
 
Memory Management in WordPress
Memory Management in WordPressMemory Management in WordPress
Memory Management in WordPress
 
Transients are good for you - WordCamp London 2016
Transients are good for you - WordCamp London 2016Transients are good for you - WordCamp London 2016
Transients are good for you - WordCamp London 2016
 
HTTP Caching and PHP
HTTP Caching and PHPHTTP Caching and PHP
HTTP Caching and PHP
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
 
Built-in query caching for all PHP MySQL extensions/APIs
Built-in query caching for all PHP MySQL extensions/APIsBuilt-in query caching for all PHP MySQL extensions/APIs
Built-in query caching for all PHP MySQL extensions/APIs
 
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
 
How Not to Build a WordPress Plugin
How Not to Build a WordPress PluginHow Not to Build a WordPress Plugin
How Not to Build a WordPress Plugin
 
Caching in WordPress
Caching in WordPressCaching in WordPress
Caching in WordPress
 
Windows Azure Storage & Sql Azure
Windows Azure Storage & Sql AzureWindows Azure Storage & Sql Azure
Windows Azure Storage & Sql Azure
 

Plus de Tareq Hasan

Grow Your Career with WordPress
Grow Your Career with WordPressGrow Your Career with WordPress
Grow Your Career with WordPressTareq Hasan
 
How to Submit a plugin to WordPress.org Repository
How to Submit a plugin to WordPress.org RepositoryHow to Submit a plugin to WordPress.org Repository
How to Submit a plugin to WordPress.org RepositoryTareq Hasan
 
Composer - The missing package manager for PHP
Composer - The missing package manager for PHPComposer - The missing package manager for PHP
Composer - The missing package manager for PHPTareq Hasan
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.pptTareq Hasan
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array PointerTareq Hasan
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.pptTareq Hasan
 
Algorithm: priority queue
Algorithm: priority queueAlgorithm: priority queue
Algorithm: priority queueTareq Hasan
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-SortTareq Hasan
 
Java: Inheritance
Java: InheritanceJava: Inheritance
Java: InheritanceTareq Hasan
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to ArraysTareq Hasan
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design ExamplesTareq Hasan
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object ReferencesTareq Hasan
 

Plus de Tareq Hasan (20)

Grow Your Career with WordPress
Grow Your Career with WordPressGrow Your Career with WordPress
Grow Your Career with WordPress
 
How to Submit a plugin to WordPress.org Repository
How to Submit a plugin to WordPress.org RepositoryHow to Submit a plugin to WordPress.org Repository
How to Submit a plugin to WordPress.org Repository
 
Composer - The missing package manager for PHP
Composer - The missing package manager for PHPComposer - The missing package manager for PHP
Composer - The missing package manager for PHP
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
chapter22.ppt
chapter22.pptchapter22.ppt
chapter22.ppt
 
chapter - 6.ppt
chapter - 6.pptchapter - 6.ppt
chapter - 6.ppt
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
chapter-8.ppt
chapter-8.pptchapter-8.ppt
chapter-8.ppt
 
chapter23.ppt
chapter23.pptchapter23.ppt
chapter23.ppt
 
chapter24.ppt
chapter24.pptchapter24.ppt
chapter24.ppt
 
Algorithm: priority queue
Algorithm: priority queueAlgorithm: priority queue
Algorithm: priority queue
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Java: Inheritance
Java: InheritanceJava: Inheritance
Java: Inheritance
 
Java: Exception
Java: ExceptionJava: Exception
Java: Exception
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design Examples
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
 

Dernier

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Dernier (20)

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

Caching in WordPress

  • 1. Caching in WordPress Tareq Hasan (@tareq_cse) http://tareq.weDevs.com
  • 2. What is Caching? • Serve static content to the visitor without querying the database. • Not generated upon **every** request • Reduce to API calls
  • 3. Type of Caching? • Page Cache - Whole page as static content • Query Cache - Cache SQL query results • Fragment Cache - Cache a piece of page • Browser Cache - Cache page assets • Opcode Cache - PHP executes faster
  • 4. WordPress Caching APIs Transients! - Persistent out of the box - Stored in wp_options get_transient() set_transient() delete_transient() Object Cache! - Not persistent without a persistent backend - Storage depends on the backend wp_cache_add() wp_cache_set() wp_cache_get() wp_cache_delete()
  • 5. Using Transients set_transient( $key, $value, $expiration ); <?php // Get any existing copy of our transient data $special_query = get_transient( 'special_query' ); if ( false === $special_query_results ) { $special_query = new WP_Query( 'cat=5&order=random' ); set_transient( 'special_query', $special_query, 12 * HOUR_IN_SECONDS ); } // Use the data like you would have normally... Queries only after each 12 hours
  • 6. Object Cache • Not persistent. Means, valid for only one pageload • Requires a persistent backend. Such as APC, Memcached. • Plugins like W3 Total Cache, Memcached Object Cache helps. • Used Extensively in WordPress • Cache objects can be grouped
  • 7. Object Cache Functions // set the cache with value wp_cache_add( $key, $data, $group, $expire ) wp_cache_set( $key, $data, $group, $expire ) // retrieve the value from cache wp_cache_get( $key, $group ) // clears data from the cache for the given key. wp_cache_replace( $key, $data, $group, $expire ) // clears all cached data. wp_cache_flush()
  • 8. Using Object Cache $result = wp_cache_get( 'my_result' ); if ( false === $result ) { $result = $wpdb->get_results( $query ); wp_cache_set( 'my_result', $result ); } // Do something with $result; http://codex.wordpress.org/Class_Reference/WP_Object_Cache
  • 9. Persistent Cache Plugins • W3 Total Cache • WP File Cache • Memcached Object Cache • APC Object Cache • WordPress Redis Backend
  • 10. Fragment Caching • Cache a fragment of a page • This could be your menubar, widgets and other query related parts. https://gist.github.com/markjaquith/2653957
  • 11. Browser Caching • HTTP Cache-Control • Expiry Headers • Entity Tags (W3-Total-Cache, WP Super Cache) http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/
  • 12. Opcode Cache php-apc + W3 Total Cache