SlideShare a Scribd company logo
Caching in
WordPress
David Biňovec
david_binovec@parade.com
Presentation outline
● What cache is, what to cache
● Caching options in PHP and MySQL
o Memcached, Alternative PHP Cache (APC)
o MySQL Query Cache
● Page level a Object Cache
● Is WordPress cache-ready?
o Transients API
o WP_Object_Cache a wp_cache funkce
o oEmbed cache
What is a cache and what to cache?
● transparently stored data so that future requests for that
data can be served faster
● You can cache almost everything
o whole pages, objects
o external API requests, resource demanding
operations ...
● … and even more
o MySQL Query Cache
o OpCode
MySQL Query Cache
● only identical and deterministic SELECT
requests
● inter session persistent
● cache flushing after the change of relevant
data
● non-distributed
Cache engines
● Memcached
o distributed (server accessible via telnet)
o key-value pairs saved in a memory
o PECL extension for PHP (memcached / memcache)
● Alternative PHP Cache (APC)
o Opcode and user cache (PHP <= 5.4), APCu (PHP 5.5)
o non-distributed
● Flat file
o eg. mod_rewrite (WP Super Cache), CDN
Page Level vs. Object Cache
● Page level cache (e.g. WP Super Cache)
o saves only whole pages
o every single page has to be generated on it’s own
with all database requests, API call etc..
o usually is not available for non logged in users
● Object cache (APC, Memcached, W3TC)
o reusable for a generation of multiple pages
o works also for logged in users
o has affect even on WordPress administration
Page Level Cache
● HTML files saved on hard drive
o loading via PHP or mod_rewrite (WP Super Cache)
● memcached (Batcache)
o can be used even without PHP (NginX, Apache ...)
● CDN
o cloudflare (W3TC)
o anything else (WP Super Cache)
How to cache a page in WordPress
WP Super Cache - mod_rewrite
Object Cache
● reusable objects
o either in terms of a single requests
o or, and with better performance, in multiple requests
● object is created via one or multiple
SELECTs
o is an output from multiple functions, methods ...
● For example:
o WP_User (capabilities, user_meta)
o WP_Post ...
Is WordPress cache-ready? It is!
● Transients API
o set_transient, get_transient, delete_transient
o set_site_transient, get_site_transient …
● WP_Object_Cache and wp_cache functions
o wp-includes/cache.php
 wp_cache_add, wp_cache_set,
wp_cache_replace
 wp_cache_get
 wp_cache_delete, wp_cache_flush
Transients API
● temporary saving of cached data
● uses wp_options table by default
o add_option with param autoload = “no”
 if no expiration is set, then autoload = “yes”
o adds two entries to the database
 transient value
 maximal expiration time (vs. guaranted time)
● it’s guaranted by default, but saving into database can be
overriden by memcache server, for instance
● core implementation of this class uses global
variable for saving data
o thus, from nature, is cached only per requests
● has it’s meaning for repeated database
requests
o you can call get_post_meta multiple time for one
request, but you reach database once only
WP_Object_Cache
Where is WP_Object_Cache used
● get_metadata (post, user, comment ...)
● get_option (autoload options)
● get_post, get_user, get_comment, get_term
● transients
● ...
wp_cache functions
● wp_cache_set($key, $data, $group, $expire)
o no expiration by default ($expire = 0)
● wp_cache_get( $key, $group )
o group allows to use same keys across multiple
groups
WP_Object_Cache dropins
● dropins
o wp-content/advanced-cache.php
o wp-content/object-cache.php
● object-cache.php
o prevents loading of wp-includes/wp_cache.php
o redefines WP_Object_Cache and wp_cache
functions
o uses any of external caching engines
 memcache, APC, filesystem ...
oEmbed cache using post_meta
WordPress Cache Plugins
● WP Super Cache http://wordpress.org/plugins/wp-super-
cache/
o page level cache using mod_rewrite
● W3 Total Cache http://wordpress.org/plugins/w3-total-cache/
o multiple object-cache engines
● Batcache http://wordpress.org/plugins/batcache/
● object-cache.php dropins
http://wordpress.org/plugins/memcached/
http://wordpress.org/plugins/apc/
Understanding Cache in WP - Summary
● Memcached, APC, MySQL Query Cache
● Page level vs. Object Cache
o go for a mix of page level and object
cache
● Transients API
● WP_Object_Cache a wp_cache funkce
o dropins: object-cache.php, advanced-cache.php
● oEmbed cache using post_meta table

More Related Content

What's hot

Active Data Stores at 30,000ft
Active Data Stores at 30,000ftActive Data Stores at 30,000ft
Active Data Stores at 30,000ft
Jeffrey Sica
 
Drupal caching
Drupal cachingDrupal caching
Drupal cachingExove
 
JMeter performance and scalability in Moodle Montana Moot 2014
JMeter performance and scalability in Moodle Montana Moot 2014JMeter performance and scalability in Moodle Montana Moot 2014
JMeter performance and scalability in Moodle Montana Moot 2014
moorejon
 
Wordpress install setup
Wordpress install setupWordpress install setup
Wordpress install setup
Mohammed Nayeem
 
Memcached And MySQL
Memcached And MySQLMemcached And MySQL
Memcached And MySQL
Chris Barber
 
Nano-node: Intelligent Hard Drives in Large Storage Infrastructures
Nano-node: Intelligent Hard Drives in Large Storage InfrastructuresNano-node: Intelligent Hard Drives in Large Storage Infrastructures
Nano-node: Intelligent Hard Drives in Large Storage Infrastructures
OpenIO Object Storage
 
Performance on Rails
Performance on RailsPerformance on Rails
Performance on Rails
Pedro Sousa
 
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
varien
 
How do i Meet MongoDB
How do i Meet MongoDBHow do i Meet MongoDB
How do i Meet MongoDB
Antonio Scalzo
 
Speed up your site with Varnish
Speed up your site with VarnishSpeed up your site with Varnish
Speed up your site with Varnish
Simon Jones
 
20170310 PHP goal pyramid for memorising
20170310 PHP goal pyramid for memorising20170310 PHP goal pyramid for memorising
20170310 PHP goal pyramid for memorising
Sharon Liu
 
Hdfs internals
Hdfs internalsHdfs internals
Hdfs internals
Bhupesh Chawda
 
Mongo performance tuning: tips and tricks
Mongo performance tuning: tips and tricksMongo performance tuning: tips and tricks
Mongo performance tuning: tips and tricks
Vladimir Malyk
 
Moodle performance testing presentation - Jonathon Moore
 Moodle performance testing presentation - Jonathon Moore Moodle performance testing presentation - Jonathon Moore
Moodle performance testing presentation - Jonathon Moore
Ireland & UK Moodlemoot 2012
 
Zend Con 2008 Slides
Zend Con 2008 SlidesZend Con 2008 Slides
Zend Con 2008 Slides
mkherlakian
 
Html5-Web-Storage
Html5-Web-StorageHtml5-Web-Storage
Html5-Web-Storage
Mindfire Solutions
 
S3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever needS3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever need
Matthew Boeckman
 
Ajax xml json
Ajax xml jsonAjax xml json
Ajax xml json
Andrii Siusko
 

What's hot (18)

Active Data Stores at 30,000ft
Active Data Stores at 30,000ftActive Data Stores at 30,000ft
Active Data Stores at 30,000ft
 
Drupal caching
Drupal cachingDrupal caching
Drupal caching
 
JMeter performance and scalability in Moodle Montana Moot 2014
JMeter performance and scalability in Moodle Montana Moot 2014JMeter performance and scalability in Moodle Montana Moot 2014
JMeter performance and scalability in Moodle Montana Moot 2014
 
Wordpress install setup
Wordpress install setupWordpress install setup
Wordpress install setup
 
Memcached And MySQL
Memcached And MySQLMemcached And MySQL
Memcached And MySQL
 
Nano-node: Intelligent Hard Drives in Large Storage Infrastructures
Nano-node: Intelligent Hard Drives in Large Storage InfrastructuresNano-node: Intelligent Hard Drives in Large Storage Infrastructures
Nano-node: Intelligent Hard Drives in Large Storage Infrastructures
 
Performance on Rails
Performance on RailsPerformance on Rails
Performance on Rails
 
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
Magento Imagine eCommerce Conference February 2011: Optimizing Magento For Pe...
 
How do i Meet MongoDB
How do i Meet MongoDBHow do i Meet MongoDB
How do i Meet MongoDB
 
Speed up your site with Varnish
Speed up your site with VarnishSpeed up your site with Varnish
Speed up your site with Varnish
 
20170310 PHP goal pyramid for memorising
20170310 PHP goal pyramid for memorising20170310 PHP goal pyramid for memorising
20170310 PHP goal pyramid for memorising
 
Hdfs internals
Hdfs internalsHdfs internals
Hdfs internals
 
Mongo performance tuning: tips and tricks
Mongo performance tuning: tips and tricksMongo performance tuning: tips and tricks
Mongo performance tuning: tips and tricks
 
Moodle performance testing presentation - Jonathon Moore
 Moodle performance testing presentation - Jonathon Moore Moodle performance testing presentation - Jonathon Moore
Moodle performance testing presentation - Jonathon Moore
 
Zend Con 2008 Slides
Zend Con 2008 SlidesZend Con 2008 Slides
Zend Con 2008 Slides
 
Html5-Web-Storage
Html5-Web-StorageHtml5-Web-Storage
Html5-Web-Storage
 
S3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever needS3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever need
 
Ajax xml json
Ajax xml jsonAjax xml json
Ajax xml json
 

Similar to Caching in WordPress

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
Ulf Wendel
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
Exove
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sitesdrupalcampest
 
Php
PhpPhp
Caching in drupal
Caching in drupalCaching in drupal
Caching in drupal
Vivek Panicker
 
Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developers
Seravo
 
Php
PhpPhp
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsZend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applications
Enrico Zimuel
 
Caching in WordPress
Caching in WordPressCaching in WordPress
Caching in WordPress
Tareq Hasan
 
Data cache management in php
Data cache management in phpData cache management in php
Data cache management in php
Andrew Yatsenko
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APC
Ben Ramsey
 
Asp.net caching
Asp.net cachingAsp.net caching
Asp.net caching
Mindfire Solutions
 
Zend Server Data Caching
Zend Server Data CachingZend Server Data Caching
Zend Server Data Caching
El Taller Web
 
Caching Up and Down the Stack
Caching Up and Down the StackCaching Up and Down the Stack
Caching Up and Down the Stack
Dan Kuebrich
 
Caching, Scaling, and What I've Learned from WordPress.com VIP
Caching, Scaling, and What I've Learned from WordPress.com VIPCaching, Scaling, and What I've Learned from WordPress.com VIP
Caching, Scaling, and What I've Learned from WordPress.com VIP
Erick Hitter
 
Caching
CachingCaching
Caching
Aaron Scherer
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
Matteo Moretti
 
Drupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case StudyDrupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case Study
hernanibf
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011
Wim Godden
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and Scalability
Mediacurrent
 

Similar to Caching in WordPress (20)

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
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Php
PhpPhp
Php
 
Caching in drupal
Caching in drupalCaching in drupal
Caching in drupal
 
Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developers
 
Php
PhpPhp
Php
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsZend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applications
 
Caching in WordPress
Caching in WordPressCaching in WordPress
Caching in WordPress
 
Data cache management in php
Data cache management in phpData cache management in php
Data cache management in php
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APC
 
Asp.net caching
Asp.net cachingAsp.net caching
Asp.net caching
 
Zend Server Data Caching
Zend Server Data CachingZend Server Data Caching
Zend Server Data Caching
 
Caching Up and Down the Stack
Caching Up and Down the StackCaching Up and Down the Stack
Caching Up and Down the Stack
 
Caching, Scaling, and What I've Learned from WordPress.com VIP
Caching, Scaling, and What I've Learned from WordPress.com VIPCaching, Scaling, and What I've Learned from WordPress.com VIP
Caching, Scaling, and What I've Learned from WordPress.com VIP
 
Caching
CachingCaching
Caching
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Drupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case StudyDrupal Performance - SerBenfiquista.com Case Study
Drupal Performance - SerBenfiquista.com Case Study
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and Scalability
 

Recently uploaded

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 

Recently uploaded (20)

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 

Caching in WordPress

  • 2. Presentation outline ● What cache is, what to cache ● Caching options in PHP and MySQL o Memcached, Alternative PHP Cache (APC) o MySQL Query Cache ● Page level a Object Cache ● Is WordPress cache-ready? o Transients API o WP_Object_Cache a wp_cache funkce o oEmbed cache
  • 3. What is a cache and what to cache? ● transparently stored data so that future requests for that data can be served faster ● You can cache almost everything o whole pages, objects o external API requests, resource demanding operations ... ● … and even more o MySQL Query Cache o OpCode
  • 4. MySQL Query Cache ● only identical and deterministic SELECT requests ● inter session persistent ● cache flushing after the change of relevant data ● non-distributed
  • 5. Cache engines ● Memcached o distributed (server accessible via telnet) o key-value pairs saved in a memory o PECL extension for PHP (memcached / memcache) ● Alternative PHP Cache (APC) o Opcode and user cache (PHP <= 5.4), APCu (PHP 5.5) o non-distributed ● Flat file o eg. mod_rewrite (WP Super Cache), CDN
  • 6. Page Level vs. Object Cache ● Page level cache (e.g. WP Super Cache) o saves only whole pages o every single page has to be generated on it’s own with all database requests, API call etc.. o usually is not available for non logged in users ● Object cache (APC, Memcached, W3TC) o reusable for a generation of multiple pages o works also for logged in users o has affect even on WordPress administration
  • 7. Page Level Cache ● HTML files saved on hard drive o loading via PHP or mod_rewrite (WP Super Cache) ● memcached (Batcache) o can be used even without PHP (NginX, Apache ...) ● CDN o cloudflare (W3TC) o anything else (WP Super Cache)
  • 8. How to cache a page in WordPress
  • 9. WP Super Cache - mod_rewrite
  • 10. Object Cache ● reusable objects o either in terms of a single requests o or, and with better performance, in multiple requests ● object is created via one or multiple SELECTs o is an output from multiple functions, methods ... ● For example: o WP_User (capabilities, user_meta) o WP_Post ...
  • 11. Is WordPress cache-ready? It is! ● Transients API o set_transient, get_transient, delete_transient o set_site_transient, get_site_transient … ● WP_Object_Cache and wp_cache functions o wp-includes/cache.php  wp_cache_add, wp_cache_set, wp_cache_replace  wp_cache_get  wp_cache_delete, wp_cache_flush
  • 12. Transients API ● temporary saving of cached data ● uses wp_options table by default o add_option with param autoload = “no”  if no expiration is set, then autoload = “yes” o adds two entries to the database  transient value  maximal expiration time (vs. guaranted time) ● it’s guaranted by default, but saving into database can be overriden by memcache server, for instance
  • 13. ● core implementation of this class uses global variable for saving data o thus, from nature, is cached only per requests ● has it’s meaning for repeated database requests o you can call get_post_meta multiple time for one request, but you reach database once only WP_Object_Cache
  • 14. Where is WP_Object_Cache used ● get_metadata (post, user, comment ...) ● get_option (autoload options) ● get_post, get_user, get_comment, get_term ● transients ● ...
  • 15. wp_cache functions ● wp_cache_set($key, $data, $group, $expire) o no expiration by default ($expire = 0) ● wp_cache_get( $key, $group ) o group allows to use same keys across multiple groups
  • 16. WP_Object_Cache dropins ● dropins o wp-content/advanced-cache.php o wp-content/object-cache.php ● object-cache.php o prevents loading of wp-includes/wp_cache.php o redefines WP_Object_Cache and wp_cache functions o uses any of external caching engines  memcache, APC, filesystem ...
  • 17. oEmbed cache using post_meta
  • 18. WordPress Cache Plugins ● WP Super Cache http://wordpress.org/plugins/wp-super- cache/ o page level cache using mod_rewrite ● W3 Total Cache http://wordpress.org/plugins/w3-total-cache/ o multiple object-cache engines ● Batcache http://wordpress.org/plugins/batcache/ ● object-cache.php dropins http://wordpress.org/plugins/memcached/ http://wordpress.org/plugins/apc/
  • 19. Understanding Cache in WP - Summary ● Memcached, APC, MySQL Query Cache ● Page level vs. Object Cache o go for a mix of page level and object cache ● Transients API ● WP_Object_Cache a wp_cache funkce o dropins: object-cache.php, advanced-cache.php ● oEmbed cache using post_meta table

Editor's Notes

  1. http://dev.mysql.com/doc/refman/5.1/en/query-cache.html
  2. http://memcached.org/ http://www.php.net/manual/en/book.apc.php http://pecl.php.net/package/memcached
  3. http://nginx.org/en/docs/http/ngx_http_memcached_module.html http://httpd.apache.org/docs/2.2/mod/mod_mem_cache.html
  4. This is just a pseudo non working code showing principles of using PHP’s output buffer with a callback and advanced-cache.php dropin.
  5. Example of mod_rewrites generated by WP Super Cache plugin for serving previously cached (saved) page
  6. http://codex.wordpress.org/Transients_API http://codex.wordpress.org/Class_Reference/WP_Object_Cache
  7. http://codex.wordpress.org/Transients_API
  8. http://codex.wordpress.org/Class_Reference/WP_Object_Cache
  9. This is a stripped code from the WordPress core