Otto Kekäläinen, the code-loving CEO of Seravo held a webinar on May 12, 2020, that focused on the cache: what should a WordPress developer know and which are the best practices to follow?
Presentation from webinar held on August 19th, 2020, with Xdebug developer Derick Rethans and Seravo CEO Otto Kekäläinen.
This presentation shows you how to use Xdebug (which is very easy with the Seravo WordPress development environment!) to make a record of what the WordPress PHP code does during a website page load, and how to use that information to optimize the performance of your WordPress site.
For a video recording and Dericks presentation see https://seravo.com/blog/webinar-xdebug-profile-php/
Search in WordPress - how it works and howto customize itOtto Kekäläinen
WordPress search customization is a topic we at Seravo get asked about on a frequent basis. There are many different ways to customize the search, and customers understandably want to learn the best practices. The search can be customized quite easily with small changes on PHP code level, and by utilizing MariaDB database’s built-in search functionality. You can also choose a more robust way to do this, and build a new ElasticSearch server just for your case.
These slides are from the webinar on January 14th, 2021: https://seravo.com/blog/webinar-search-function-and-how-to-customize-it/
The 5 most common reasons for a slow WordPress site and how to fix them – ext...Otto Kekäläinen
Presentation given in WP Meetup in October 2019.
Includes fresh new tips from summer/fall 2019!
A Must read for all WordPress site owners and developers.
How to investigate and recover from a security breach in WordPressOtto Kekäläinen
Talk given at the first ever WordCamp Nordic on March 8th, 2019.
How to investigate and recover from a security breach – real-life experiences with WordPress
Sometimes the bad guys get in, despite all the protections and precautions. If that happens, there are many techniques that can be used to stop further damage, track down what the intruder did and how they got in. Finally the site needs to be cleaned up and re-opened for visitors. In this talk the most important techniques are presented along with real-life examples when they were used.
10 things every developer should know about their database to run word press ...Otto Kekäläinen
Talk from WordCamp Barcelona 2018
https://2018.barcelona.wordcamp.org/session/10-things-every-developer-should-know-about-their-database-to-run-wordpress-optimally/
The database is perhaps the most important piece of your infrastructure. The database contains all your important e-commerce data and must be kept secured. The database performance often defines the overall performance of your WordPress site. In this talk I the most important things every WordPress developer should know about MariaDB/MySQL to be able to build and operate their site optimally.
Improving WordPress Performance with Xdebug and PHP ProfilingOtto Kekäläinen
Presentation given at WordCamp Europe 2017 in Paris 2017-06-16.
Xdebug is a tool for developers to gain insight into how PHP is executed. Using it for profiling is a very effective, fast and precise method to find bottlenecks in your WordPress site. In this talk I explain how to use it with Webgrind, how to find potential optimization targets, show examples of real cases when Xdebug helped fix a performance problem and also explain what Xdebug is not suitable for and what can be used instead. If you are not a developer, you’ll learn what Xdebug is capable of and when to ask a developer to use it.
Presentation from webinar held on August 19th, 2020, with Xdebug developer Derick Rethans and Seravo CEO Otto Kekäläinen.
This presentation shows you how to use Xdebug (which is very easy with the Seravo WordPress development environment!) to make a record of what the WordPress PHP code does during a website page load, and how to use that information to optimize the performance of your WordPress site.
For a video recording and Dericks presentation see https://seravo.com/blog/webinar-xdebug-profile-php/
Search in WordPress - how it works and howto customize itOtto Kekäläinen
WordPress search customization is a topic we at Seravo get asked about on a frequent basis. There are many different ways to customize the search, and customers understandably want to learn the best practices. The search can be customized quite easily with small changes on PHP code level, and by utilizing MariaDB database’s built-in search functionality. You can also choose a more robust way to do this, and build a new ElasticSearch server just for your case.
These slides are from the webinar on January 14th, 2021: https://seravo.com/blog/webinar-search-function-and-how-to-customize-it/
The 5 most common reasons for a slow WordPress site and how to fix them – ext...Otto Kekäläinen
Presentation given in WP Meetup in October 2019.
Includes fresh new tips from summer/fall 2019!
A Must read for all WordPress site owners and developers.
How to investigate and recover from a security breach in WordPressOtto Kekäläinen
Talk given at the first ever WordCamp Nordic on March 8th, 2019.
How to investigate and recover from a security breach – real-life experiences with WordPress
Sometimes the bad guys get in, despite all the protections and precautions. If that happens, there are many techniques that can be used to stop further damage, track down what the intruder did and how they got in. Finally the site needs to be cleaned up and re-opened for visitors. In this talk the most important techniques are presented along with real-life examples when they were used.
10 things every developer should know about their database to run word press ...Otto Kekäläinen
Talk from WordCamp Barcelona 2018
https://2018.barcelona.wordcamp.org/session/10-things-every-developer-should-know-about-their-database-to-run-wordpress-optimally/
The database is perhaps the most important piece of your infrastructure. The database contains all your important e-commerce data and must be kept secured. The database performance often defines the overall performance of your WordPress site. In this talk I the most important things every WordPress developer should know about MariaDB/MySQL to be able to build and operate their site optimally.
Improving WordPress Performance with Xdebug and PHP ProfilingOtto Kekäläinen
Presentation given at WordCamp Europe 2017 in Paris 2017-06-16.
Xdebug is a tool for developers to gain insight into how PHP is executed. Using it for profiling is a very effective, fast and precise method to find bottlenecks in your WordPress site. In this talk I explain how to use it with Webgrind, how to find potential optimization targets, show examples of real cases when Xdebug helped fix a performance problem and also explain what Xdebug is not suitable for and what can be used instead. If you are not a developer, you’ll learn what Xdebug is capable of and when to ask a developer to use it.
Find Site Performance from the server to WordPress. A look at how some good performance gains can be made in tuning MySQL and APC and getting the most of out W3 Total Cache.
Automatic testing and quality assurance for WordPress plugins and themesOtto Kekäläinen
Talk given at WP Helsinki Meetup 7.11.2018
See also:
* https://developer.wordpress.org/themes
* https://developer.wordpress.org/plugins
* https://travis-ci.org/Seravo
* https://seravo.com/blog/coding-wordpress-in-style-with-phpcs/
Automatic testing and quality assurance for WordPress pluginsOtto Kekäläinen
Talk given at WordCamp Jyväskylä 2018
WordPress plugins have a reputation of low quality. Help us prove them wrong. Start using automatic quality testing!
Slides from my speech about web apps performance. Images, CSS, JS optimization. PHP and HTTP server effects + caching. Performance profiling with Blackfire.io, debugging with Xdebug.
Presentation given at the WP Jyväksylä Meetup March 21st, 2017. This revised version contains references to the WordPress security news that circulated in February 2017.
EasyEngine - Command-Line tool to manage WordPress Sites on NginxrtCamp
EasyEngine is a Command Line Tool to Manage WordPress Sites on Nginx Server.
Apart from site management, it installs php, mysql, nginx, postfix, memcache and everything else required to run high traffic WordPress sites.
You can serve millions of page-views on $5 digitalocean plan using EasyEngine! ;-)
These slides are from WordCamp Mumbai 2014 session.
Sessions. We all hear about them. We probably are using them. But do you know how they work? If you are anything like me, when you started programming you just accepted sessions as one of the many "black boxes" of programming. Then, one day, you need to debug a session issue. Or maybe you need your session to span multiple servers set up behind a load balancer. Do you know your options? Better yet, do you know your basics?
This is a beginner session tackling the very basics of sessions in CFML including:
What is a session?
What is the difference between a session and cookies?
What should I put in a session?
How does ColdFusion know which session is mine?
What is the difference between a ColdFusion and J2EE session?
How can I see what sessions are currently running?
How do I manage sessions across multiple servers?
What are some common session gotchas?
And more...
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”Valent Mustamin
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
, by Harry Sufehmi (http://twitter.com/sufehmi), for WORDCAMPID - WordCamp Indonesia 2010. Auditorium Gunadarma University, Depok, January 30, 2010
Caching and tuning fun for high scalability @ FOSDEM 2012Wim Godden
Caching has been a 'hot' topic for a few years. But caching takes more than merely taking data and putting it in a cache : the right caching techniques can improve performance and reduce load significantly. But we'll also look at some major pitfalls, showing that caching the wrong way can bring down your site. If you're looking for a clear explanation about various caching techniques and tools like Memcached, Nginx and Varnish, as well as ways to deploy them in an efficient way, this talk is for you.
Caching and tuning fun for high scalabilityWim Godden
Caching has been a 'hot' topic for a few years. But caching takes more than merely taking data and putting it in a cache : the right caching techniques can improve performance and reduce load significantly. But we'll also look at some major pitfalls, showing that caching the wrong way can bring down your site. If you're looking for a clear explanation about various caching techniques and tools like Memcached, Nginx and Varnish, as well as ways to deploy them in an efficient way, this talk is for you.
Find Site Performance from the server to WordPress. A look at how some good performance gains can be made in tuning MySQL and APC and getting the most of out W3 Total Cache.
Automatic testing and quality assurance for WordPress plugins and themesOtto Kekäläinen
Talk given at WP Helsinki Meetup 7.11.2018
See also:
* https://developer.wordpress.org/themes
* https://developer.wordpress.org/plugins
* https://travis-ci.org/Seravo
* https://seravo.com/blog/coding-wordpress-in-style-with-phpcs/
Automatic testing and quality assurance for WordPress pluginsOtto Kekäläinen
Talk given at WordCamp Jyväskylä 2018
WordPress plugins have a reputation of low quality. Help us prove them wrong. Start using automatic quality testing!
Slides from my speech about web apps performance. Images, CSS, JS optimization. PHP and HTTP server effects + caching. Performance profiling with Blackfire.io, debugging with Xdebug.
Presentation given at the WP Jyväksylä Meetup March 21st, 2017. This revised version contains references to the WordPress security news that circulated in February 2017.
EasyEngine - Command-Line tool to manage WordPress Sites on NginxrtCamp
EasyEngine is a Command Line Tool to Manage WordPress Sites on Nginx Server.
Apart from site management, it installs php, mysql, nginx, postfix, memcache and everything else required to run high traffic WordPress sites.
You can serve millions of page-views on $5 digitalocean plan using EasyEngine! ;-)
These slides are from WordCamp Mumbai 2014 session.
Sessions. We all hear about them. We probably are using them. But do you know how they work? If you are anything like me, when you started programming you just accepted sessions as one of the many "black boxes" of programming. Then, one day, you need to debug a session issue. Or maybe you need your session to span multiple servers set up behind a load balancer. Do you know your options? Better yet, do you know your basics?
This is a beginner session tackling the very basics of sessions in CFML including:
What is a session?
What is the difference between a session and cookies?
What should I put in a session?
How does ColdFusion know which session is mine?
What is the difference between a ColdFusion and J2EE session?
How can I see what sessions are currently running?
How do I manage sessions across multiple servers?
What are some common session gotchas?
And more...
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”Valent Mustamin
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
, by Harry Sufehmi (http://twitter.com/sufehmi), for WORDCAMPID - WordCamp Indonesia 2010. Auditorium Gunadarma University, Depok, January 30, 2010
Caching and tuning fun for high scalability @ FOSDEM 2012Wim Godden
Caching has been a 'hot' topic for a few years. But caching takes more than merely taking data and putting it in a cache : the right caching techniques can improve performance and reduce load significantly. But we'll also look at some major pitfalls, showing that caching the wrong way can bring down your site. If you're looking for a clear explanation about various caching techniques and tools like Memcached, Nginx and Varnish, as well as ways to deploy them in an efficient way, this talk is for you.
Caching and tuning fun for high scalabilityWim Godden
Caching has been a 'hot' topic for a few years. But caching takes more than merely taking data and putting it in a cache : the right caching techniques can improve performance and reduce load significantly. But we'll also look at some major pitfalls, showing that caching the wrong way can bring down your site. If you're looking for a clear explanation about various caching techniques and tools like Memcached, Nginx and Varnish, as well as ways to deploy them in an efficient way, this talk is for you.
Caching and tuning fun for high scalability @ phpBenelux 2011Wim Godden
Slides for "Caching and Tuning fun for high scalability" talk, given @ phpBenelux Conference - Jan 28, 2011
Note that a lot of things were explained with each slide... that content is ofcourse not in the slides, so it might make some slides very unclear.
High Availability Content Caching with NGINXNGINX, Inc.
On-Demand Recording:
https://www.nginx.com/resources/webinars/high-availability-content-caching-nginx/
You trust NGINX to be your web server, but did you know it’s also a high-performance content cache? In fact, the world’s most popular CDNs – CloudFlare, MaxCDN, and Level 3 among them – are built on top of the open source NGINX software.
NGINX content caching can drastically improve the performance of your applications. We’ll start with basic configuration, then move on to advanced concepts and best practices for architecting high availability and capacity in your application infrastructure.
Join this webinar to:
* Enable content caching with the key configuration directives
* Use micro caching with NGINX Plus to cache dynamic content while maintaining low CPU utilization
* Partition your cache across multiple servers for high availability and increased capacity
* Log transactions and troubleshoot your NGINX content cache
These slides show how to reduce latency on websites and reduce bandwidth for improved user experience.
Covering network, compression, caching, etags, application optimisation, sphinxsearch, memcache, db optimisation
Caching and tuning fun for high scalabilityWim Godden
Caching has been a 'hot' topic for a few years. But caching takes more than merely taking data and putting it in a cache : the right caching techniques can improve performance and reduce load significantly. But we'll also look at some major pitfalls, showing that caching the wrong way can bring down your site.
If you're looking for a clear explanation about various caching techniques and tools like Memcached, Nginx and Varnish, as well as ways to deploy them in an efficient way, this talk is for you.
When people hear the word NGINX, they usually associate the open source platform for its popular adoption as an HTTP web server or load balancer. What a lot of people don't know is the vast amount of powerful features contained in the platform that can be used to build an HTTP caching layer and why NGINX is often used as a framework to build powerful, scalable and highly available content delivery networks. In this talk we will dive into each unique NGINX directive and its configuration options that are available. We will show different architectural approaches that can be used to build a highly available HTTP content cache layer. We will show various other NGINX configurations that can be critical to your NGINX deployment. Walking away from this presentation, attendees will have the knowledge required to configure basic and advanced caching of their NGINX servers.
In this presentation, I show the audience how to implement HTTP caching best practices in a non-intrusive way in PHP Symfony 4 code base.
This presentation focuses on topics like:
- Caching using cache-control headers
- Cache variations using the Vary header
- Conditional requests using headers like ETag & If-None-Match
- ESI discovery & parsing using headers like Surrogate-Capability & Surrogate-Control
- Caching stateful content using JSON Web Token Validation in Varnish
More information about this presentation is available at https://feryn.eu/speaking/developing-cacheable-php-applications-php-limburg-be/
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...Ontico
В докладе я расскажу, что такое Web-акселератор, он же reverse proxy и он же - фронтенд. Как следует из названия, он ускоряет сайт. Но за счет чего он это делает? Какие они, вообще, бывают? Что они умеют, а что нет? В чем особенности каждого из решений? И, вообще, постараюсь рассказать о них вглубь и вширь.
Еще я расскажу про еще один Open Source Web-акселератор - Tempesta FW. Уникальность проекта в том, что это гибрид Web-акселератора и файервола, разрабатываемый специально для обработки и фильтрации больших объемов HTTP трафика. Основные сценарии использования системы — это защита от DDoS прикладного уровня и просто доставка больших объемов HTTP трафика малыми затратами на оборудование.
- Что такое Web-акселератор, зачем он был придуман и как понять когда он нужен;
- Типичный функционал reverse proxy, его отличия от Web-сервера;
- Упомянем про SSL акселераторы;
- Заглянем вглубь HTTP, и как он управляет кэшированием и проксированием, что может быть закэшированно, а что - нет;
- Мы сравним наиболее популярные акселераторы (Nginx, Varnish, Apache Traffic Server, Apache HTTPD, Squid) по фичам и внутренностям;
- Зачем нужен еще один Web-акселератор Tempesta FW, и в чем его отличие от других акселераторов.
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesSanjeev Rampal
Talk presented at Kubernetes Community Day, New York, May 2024.
Technical summary of Multi-Cluster Kubernetes Networking architectures with focus on 4 key topics.
1) Key patterns for Multi-cluster architectures
2) Architectural comparison of several OSS/ CNCF projects to address these patterns
3) Evolution trends for the APIs of these projects
4) Some design recommendations & guidelines for adopting/ deploying these solutions.
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC
Ellisha Heppner, Grant Management Lead, presented an update on APNIC Foundation to the PNG DNS Forum held from 6 to 10 May, 2024 in Port Moresby, Papua New Guinea.
# Internet Security: Safeguarding Your Digital World
In the contemporary digital age, the internet is a cornerstone of our daily lives. It connects us to vast amounts of information, provides platforms for communication, enables commerce, and offers endless entertainment. However, with these conveniences come significant security challenges. Internet security is essential to protect our digital identities, sensitive data, and overall online experience. This comprehensive guide explores the multifaceted world of internet security, providing insights into its importance, common threats, and effective strategies to safeguard your digital world.
## Understanding Internet Security
Internet security encompasses the measures and protocols used to protect information, devices, and networks from unauthorized access, attacks, and damage. It involves a wide range of practices designed to safeguard data confidentiality, integrity, and availability. Effective internet security is crucial for individuals, businesses, and governments alike, as cyber threats continue to evolve in complexity and scale.
### Key Components of Internet Security
1. **Confidentiality**: Ensuring that information is accessible only to those authorized to access it.
2. **Integrity**: Protecting information from being altered or tampered with by unauthorized parties.
3. **Availability**: Ensuring that authorized users have reliable access to information and resources when needed.
## Common Internet Security Threats
Cyber threats are numerous and constantly evolving. Understanding these threats is the first step in protecting against them. Some of the most common internet security threats include:
### Malware
Malware, or malicious software, is designed to harm, exploit, or otherwise compromise a device, network, or service. Common types of malware include:
- **Viruses**: Programs that attach themselves to legitimate software and replicate, spreading to other programs and files.
- **Worms**: Standalone malware that replicates itself to spread to other computers.
- **Trojan Horses**: Malicious software disguised as legitimate software.
- **Ransomware**: Malware that encrypts a user's files and demands a ransom for the decryption key.
- **Spyware**: Software that secretly monitors and collects user information.
### Phishing
Phishing is a social engineering attack that aims to steal sensitive information such as usernames, passwords, and credit card details. Attackers often masquerade as trusted entities in email or other communication channels, tricking victims into providing their information.
### Man-in-the-Middle (MitM) Attacks
MitM attacks occur when an attacker intercepts and potentially alters communication between two parties without their knowledge. This can lead to the unauthorized acquisition of sensitive information.
### Denial-of-Service (DoS) and Distributed Denial-of-Service (DDoS) Attacks
This 7-second Brain Wave Ritual Attracts Money To You.!nirahealhty
Discover the power of a simple 7-second brain wave ritual that can attract wealth and abundance into your life. By tapping into specific brain frequencies, this technique helps you manifest financial success effortlessly. Ready to transform your financial future? Try this powerful ritual and start attracting money today!
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBrad Spiegel Macon GA
Brad Spiegel Macon GA’s journey exemplifies the profound impact that one individual can have on their community. Through his unwavering dedication to digital inclusion, he’s not only bridging the gap in Macon but also setting an example for others to follow.
1.Wireless Communication System_Wireless communication is a broad term that i...JeyaPerumal1
Wireless communication involves the transmission of information over a distance without the help of wires, cables or any other forms of electrical conductors.
Wireless communication is a broad term that incorporates all procedures and forms of connecting and communicating between two or more devices using a wireless signal through wireless communication technologies and devices.
Features of Wireless Communication
The evolution of wireless technology has brought many advancements with its effective features.
The transmitted distance can be anywhere between a few meters (for example, a television's remote control) and thousands of kilometers (for example, radio communication).
Wireless communication can be used for cellular telephony, wireless access to the internet, wireless home networking, and so on.
4. Top-notch performance
A comparison published by a
Google employee at
ismyhostfastyet.com
confirms that Seravo’s
customer sites load faster
than competing services’.
The study used
time-to-first-byte (TTFB)
measurement data from real
users as collected from the
Chrome browser UX data. Fast/Average/Slow TTFB by WordPress Host
5. “There are only two hard
things in Computer Science:
cache invalidation and
naming things.”
– Phil Karlton
6. Caches are everywhere
● Inside the CPU (levels L1-L4).
○ No need to retrieve data from RAM over and over again.
● In operating system (Linux) to protect the hard drives.
○ Prevents different programs from continuously reading the same file from the hard drive.
● Some programs have built-in caches:
○ PHP
■ Saves files so that there is no need to download them from the hard drive every second.
■ Saves the interpreted PHP code so that it does not have to be constantly recompiled.
○ Database
■ Uses plenty of cache (RAM) so that the hard drive does not need to be read as often.
○ WordPress
■ Stores transients in the database so that the following queries do not have to be as
extensive.
...and these are just couple of examples. The list is long.
7. Caches are everywhere, because...?
● Speed!
○ Can you say instantly how much is 5 times 5? Yes, because the
result is already in your memory.
○ How about 55 times 555? Hmm… Probably have to count that one.
● Not everything can be stored in the memory, so it is a good idea to save
only things you are likely need several times again later on.
8. The numbers every coder should know
● Retrieval times for different types of memories:
○ L1 cache: 1 nanosecond
○ L2 cache: 3 ns
○ L3 cache: 10 ns
○ RAM: 25 ns
○ PCIe NVMe hard drive: 2000 ns – most Seravo customers
○ SSD hard drive: 100 000 ns – few Seravo customers
○ HDD hard drive: 10 000 000 ns – none of Seravo’s customers
○ Tampere-Berlin ping: 30 000 000 ns
○ HTML-page from Nginx 2 000 000 ns
○ HTML-page from PHP/WP 50 000 000 – 1 000 000 000 ns
9. Should the cache contain everything?
● Not everything can be stored in the memory, so you
should only store things that will most likely be
needed twice or more.
● If something is not needed, clear the cache:
○ Clearing by command, so called “cache purge”.
○ A built-in mechanism, e.g. a counter to tell how many times the data has been retrieved
in the past hour.
● The cache can be cleared at any time, and some
systems do so on a regular basis.
● In addition, the cache can expire.
10. Difficult: Cache invalidation
● In what time will the cache expire?
○ 5 seconds?
○ 60 seconds?
○ 15 minutes?
○ 7 days?
● It depends. That is why it is so difficult.
11. Cache concepts
Retrieval time – has to be faster from cache than the source in order to get savings.
Invalidation – the criteria for deleting data from the cache.
Expiry – the time in which the data expires and is removed from the cache.
Bypass – intentionally bypasses the cache.
Miss – if the cache is empty, retrieves the latest data.
Hit rate – hit/miss-ratio, how often the data was found in the cache (ideally 99,99 %).
15. Browser HTTP cache
● Objective: to avoid unnecessary network traffic.
● The browser stores pages and files purely based on
what the HTTP headers say.
● Make sure your site sends sensible HTTP headers and
content expiration dates.
● WordPress does not do this as a standard.
16. An example: WP 5.3.2 CSS file
$ curl -IL https://seravo.com/wp-includes/css/dist/block-library/style.min.css?ver=5.3.2
HTTP/2 200
server: nginx
date: Wed, 29 Apr 2020 05:33:47 GMT
content-type: text/css
last-modified: Tue, 28 Apr 2020 11:42:09 GMT
etag: "5ea81691-1d52e"
expires: Thu, 07 May 2020 05:33:45 GMT
cache-control: max-age=691200
x-proxy-cache: HIT P: A: N: H:0 O: S:
x-powered-by: Seravo
x-seravo-request-id: dd1d5d1e649b5f675269a54e86dabacb
The server tells the browser that the content is valid for seven days. The length of the time
does not matter.
However, the content in the address style.min.css?ver=5.3.2 stays the same so it must be
updated with a new version number if the content is updated. Otherwise the page will be
“broken” for seven days for old visitors.
17. An example: theme’s CSS file
wp_enqueue_style(
'seravo', get_stylesheet_directory_uri() . '/dist/layout.min.css',
false,
wp_get_theme()->get('Version')
);
=> https://seravo.com/wp-content/themes/seravo/dist/layout.min.css?ver=1.2.3
If you download style files or scripts without version numbers, the browser will always have the
same layout.min.css.
However, if you add the version number, the download happens with an address
layout.min.css?ver=1.2.3 which ensures that whenever there is a new version of the theme,
the browser will also download a new version of the style file.
18. An example: seravo.com CSS file
wp_enqueue_style(
'seravo', get_stylesheet_directory_uri() . '/dist/layout.min.css',
false,
seravo_get_git_commit_id()
);
=> https://seravo.com/wp-content/themes/seravo/dist/layout.min.css?ver=c98272d0
function seravo_get_git_commit_id() {
// Don't use shell_exec('git rev-parse --short HEAD') or similar since it
// would spawn a shell session on every WordPress load of every page.
// Instead read directly from .git/logs/HEAD to as efficient as possible.
$git_log_file = '/data/wordpress/.git/logs/HEAD';
if ( is_readable($git_log_file) ) {
$lines = file($git_log_file);
$last_line = array_pop($lines);
$fields = explode(' ', $last_line);
return substr($fields[1], 0, 8);
} else {
return wp_get_theme()->get('Version');
}
}
19. Content expiration date
header.php:
$seconds_to_cache = 3600; // 1 hour
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
header("Expires: $ts");
header("Cache-Control: max-age=$seconds_to_cache");
=>
expires: Wed, 29 Apr 2020 06:55:49 GMT
cache-control: max-age=3600
In dynamic files the validity period comes from PHP. WordPress itself does not set a default
expiration date. If desired, the theme can set it using HTTP headers if the page is rarely
updated or the refresh delay is irrelevant.
The validity period for static files (e.g. style.css or script.js) comes from the HTTP server
settings. At Seravo static files have seven day expiration and cache control by default.
20. Blocking content expiration date
nocache_headers();
=>
expires: Wed, 11 Jan 1984 05:00:00 GMT
cache-control: no-cache, must-revalidate, max-age=0
WordPress (or a theme or a plugin) sometimes blocks itself the content expiration date with a
nocache_headers() -function.
21. Server HTTP cache
● Objective: to avoid unnecessary PHP execution and to
provide an HTML file directly from the memory.
● The server cache (as well as the browser!) stores
pages and files purely based on what the HTTP
headers say.
● Once again, make sure your site sends sensible HTTP
headers and content expiration dates.
22. Tool: wp-speed-test
$ wp-speed-test
Testing speed URL https://seravo.com...
URL TOTAL NAMELOOKUP CONNECT APPCONNECT PRETRANSFER STARTTRANSFER = AVG
https://seravo.com 0.161 0.004 0.005 0.011 0.011 0.159 0.161
https://seravo.com 0.124 0.000 0.000 0.000 0.000 0.122 0.142
https://seravo.com 0.113 0.000 0.000 0.000 0.000 0.111 0.132
https://seravo.com 0.216 0.000 0.000 0.000 0.000 0.215 0.153
$ wp-speed-test --cache
Testing speed URL https://seravo.com...
Warning: invoked with --cache and thus measuring cached results. This does not measure actual PHP speed.
URL TOTAL NAMELOOKUP CONNECT APPCONNECT PRETRANSFER STARTTRANSFER = AVG
https://seravo.com 0.015 0.004 0.004 0.012 0.012 0.013 0.015
https://seravo.com 0.009 0.000 0.000 0.000 0.000 0.007 0.009
https://seravo.com 0.002 0.000 0.000 0.000 0.000 0.001 0.006
https://seravo.com 0.006 0.000 0.000 0.000 0.000 0.005 0.006
If --cache gives a better result, the HTTP-level server cache is working correctly. By default, the
wp-speed-test always overrides the cache (it is not nginx- but wp-speed-test).
23. Tool: wp-check-http-cache
$ wp-check-http-cache
----------------------------------------
Seravo HTTP cache checker
----------------------------------------
Testing https://example.com...
Request 1: MISS
Request 2: MISS
Request 3: MISS
----------------------------------------
FAILED: HTTP cache does not work for https://example.com.
----------------------------------------
Please review these headers and try to find what emits them:
expires: Wed, 11 Jan 1984 05:00:00 GMT
cache-control: no-transform, no-cache, no-store, must-revalidate
----------------------------------------
You can also test this yourself by running:
curl -IL https://example.com
The site probably has WP_DEBUG or nocache_headers() on through some other route because of
the 1984.
24. Tool: wp-check-http-cache
$ wp-check-http-cache
----------------------------------------
Seravo HTTP cache checker
----------------------------------------
Testing https://seravo.com...
Request 1: HIT
Request 2: HIT
Request 3: HIT
----------------------------------------
SUCCESS: HTTP cache works for https://seravo.com.
----------------------------------------
You can also test this yourself by running:
curl -IL https://seravo.com
The site is not sending HTTP headers that would prevent server-level caching.
25. Intentionally bypassing the cache
Most sites want HTTP-level caching enabled. An exception is a page that has content
customized for one user only, such as showing “Hello Otto!” to an identified user or a
WooCommerce shopping cart.
By default the shopping cart is displayed empty and caching is enabled, but as soon as the user
puts something in the cart, customized content should be displayed to that particular visitor,
and the event should not be cached.
WooCommerce makes sure this happens by setting cookies woocommece_items_in_cart and
woocommerce_cart_hash that automatically prevent the cache from working, as they indicate
user-specific content.
26. Can the server cache slow down the page?
Additional layers of caching can reduce the need to retrieve information directly from the
source. The best cache is in the browser itself. An attractive option may be to cache a server
that is close to the user. However, recycling traffic through the CDN can also increase the delay.
For example, the direct connection is 90 ms but the use of WooCommerce via CDN is 60 + 60
ms = 120 ms => 30 % slower. Be sure to measure before and after!
Read more: https://seravo.com/blog/does-cloudflare-help-my-wordpress-site/
Open the
shopping cart
User in
Berlin
Server in
Helsinki
Server in
Amsterdam
HTTP/2-connection, connect+fetch 90 ms
HTTP/2-connection, c+f 60 ms
HTTP/2-connection, c+f 60 ms
27. Seravo’s feature: server caching
● A standard WordPress page is server-level cached for 10 minutes by
default (see the action by looking at HIT/MISS lines in the HTTP
response).
● The server-level cache can be cleared with the wp-purge-cache
command.
● ...or skipped by loading the page with Ctrl+F5.
● If the page is broken (e.g. PHP syntax error), stale cache enters the
game and displays the page from the cache while the coder adds the
missing semicolon etc.
29. WordPress transients
// Check for transient. If none, then execute WP_Query
if ( false === ( $featured = get_transient( 'foo_featured_posts' ) ) ) {
$featured = new WP_Query(
array(
'category' => 'featured',
'posts_per_page' => 5
));
// Put the results in a transient. Expire after 12 hours.
set_transient( 'foo_featured_posts', $featured, 12 * HOUR_IN_SECONDS );
}
WordPress’ own built-in cache for storing data for later use (e.g. one minute or one hour).
Stores in the database by default, but can also use for example only RAM if object-cache.php
is used and e.g. Redis server is available (as is the case for all Seravo clients).
Transient API in brief: get_transient(), set_transient() ja delete_transient()
For more information: https://seravo.com/blog/faster-wordpress-with-transients/
Always remember expiry! Otherwise
WP may load data via
wp_load_alloptions() with each site load!
30. WordPress object cache
● Objective: to avoid repetitive database queries during
the same PHP page load.
31. WP object cache
function prefix_get_post_count( $post_status = 'publish' ) {
$cache_key = 'prefix_post_count_'. $post_status;
$_posts = wp_cache_get( $cache_key );
if ( false === $_posts ) {
$_posts = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = %s",
$post_status
));
wp_cache_set( $cache_key, $_posts );
}
return $_posts;
}
For example, stores database query results in PHP’s memory, so that queries made in different
parts of WordPress code during the same PHP run do not have to be repeated many times.
NOTE: I have never used wp_cache_*. The Transient API is what a site developer really needs!
Example page https://developer.wordpress.org/reference/functions/wp_cache_get/
32. File system cache
● Objective: to avoid unnecessary hard drive operations
in general for any program.
● Seravo’s got you covered!
33. Database cache
● Objective: to avoid unnecessary hard drive operations
in the database in particular.
● Seravo’s got you covered!
34. Tideways
Xdebug is a good tool for profiling
PHP code in a local development
environment.
In a production environment Seravo
recommends Tideways.com
service.
seravo.com/docs/development/xdebug/
seravo.com/docs/development/tideways/
38. See also
Make Your Site Faster with Caching
https://seravo.com/blog/wordpress-cache/
300% faster WordPress load times with transients
https://seravo.com/blog/faster-wordpress-with-transients/
5 common reasons why your WordPress site is slow
https://youtu.be/8sJExUO-U4A
Improving WordPress Performance with XDebug and PHP Profiling
https://youtu.be/oKcIS5A-6_c