Caching in WordPress – Webkul Blog

What is caching

Caching is storing frequently used data in a storage location that can be quickly retrieved.

In Other words, techniques used to minimize efforts in generating similar results, again and again, are known as caching.

WordPress Caching Methods

There are two types of caching, server-side caching, and client-side caching.

Server-side caching is where a copy of generated result (page) is saved on the hosting server and it is served on subsequent requests.

Client-side caching is where the output content is stored on the visitor’s computer, such as browser caching.

Then there are a few different caching methods you can use with WordPress.

They are:

Browser Caching

When a user visits the site the first time and requests for a web page from the server, the web server collects the information from the request and creates the view of the page then renders it to the visitor’s browser. Have a look at the below image.

Now when the user visits the same page again, now the cached resources will be served as shown in the below image.

second-time-user

Page caching

In this type of caching a copy of page HTML is get stored on the server side when someone makes the request for the first time, and in a subsequent request, the cached HTML gets rendered thus it reduces the number of requests to speed up the page loading.

Database Caching

In this process, result from complex and expensive queries are stored in the transient or file to minimize the query response time. WordPress provides a transient mechanism to save time-based results in the options table to facilitate database caching.

Opcode caching

OPcache is a type of caching system that saves precompiled script bytecode in a server’s memory called a cache, so each time a user visits a web page, it loads faster.

OPcache is a type of OPcode caching that compiles human-readable PHP code to code your server understands which is called opcode. This occurs when the PHP file loads on a web page for the first time. Then, it’s saved to the server’s memory for faster loading at each subsequent page visit.

Bytecode cache engines such as OPcache, APC, and Xcache all complete this process the first time the PHP file is executed without having to do it a second, or third time.
If you have PHP version 5.5 and above, OPcache PHP opcode caching is installed and enabled by default.

CDN caching

A content delivery network (CDN) works by using servers around the world to store static files like pages, posts, images, and media.

A CDN takes static copies of your site and distributes them across its network.

All traffic is then redirected to the CDN.

The CDN analyzes where the visitor comes from, chooses the server closest to them and serves the page from there.

As sending data over distance takes time, the shorter the distance, the shorter the time it takes to deliver content to a visitor.


Source link