Home CMS Tutorial WordPress How to optimize WordPress

How to optimize WordPress

Jul 12, 2019 am 11:55 AM
wordpress

How to optimize WordPress

How to optimize WordPress

WordPress optimization experience and skills:

Separation of dynamic and static

No matter whether it is a WordPress blog or a site built by other CMS, the first step in optimization must be the separation of dynamic and static. This is why you see Sina, Tencent and other portals, their pictures The domain name and the domain name of the website are not the same.

There are generally two types of static files on websites: the first is the CSS, JS and common background images and button files of some themes. If the website does not undergo revision or other changes, these images will basically not be used. Will be modified. The second type is the pictures or attachments uploaded in the website content that are updated every day. These picture files will basically not be changed.

After solving static file storage and acceleration, website performance can be basically guaranteed first. The same is true for websites and blogs built by WordPress. For these static files, the best solution is always to use the CDN network for acceleration. In this way, the pressure on the server will be greatly reduced, because only the current page is on your own server when accessing the page, and all other images, JS and CSS are. Obtained from CDN.

How to use CDN services for WordPress blogs? The WPJAM Basic plug-in I wrote already supports three cloud storage services: Alibaba Cloud OSS, Qiniu Cloud Storage and UCloud Ufile. As long as you install the WPJAM Basic plug-in, you can Achieve CDN acceleration of WordPress blog static files with one click.

Server Optimization

After optimizing the static files, we must start optimizing the dynamic content of the website. To optimize dynamic content, we must first have a stable network environment. Stable Hosting provider and server performance optimization.

Choose a reliable hosting provider. I personally recommend BGP or a multi-line computer room, so that users across the country can access it at a good speed. Then try to choose an independent server. Even if it is not possible, you can still get a VPS, because you Many things cannot be done without the root authority of the server. Generally recommended in China: Alibaba Cloud.

After the server problem is solved, the server can be optimized as follows:

Install Memcached and PHP Memcached extension: Use Memcached to cache WordPress data.

PHP Turn on OPCache: cache the compiled PHP code into shared memory, and call it directly when the user accesses it to achieve efficient acceleration.

MySQL Set up MySQL Query Cache to save query results. The same query will no longer be retrieved from the database, which greatly improves the speed.

WordPress Cache

To completely understand and understand WordPress performance optimization, you must first understand the WordPress caching mechanism. WordPress defaults to an object caching mechanism called WordPress Object Cache. , it caches the content that needs to be cached according to the Key-Value pattern (somewhat similar to No-SQL's key-value). Of course, it also supports dividing the cached content according to Group and avoiding cached content conflicts.

So the most basic WordPress caching plug-in is to save the Key-Value generated by WordPress. If you use Memcached, it is saved in the memory. If you use Flie, it is saved in the hard disk. Of course, advanced WordPress plug-ins also It can do more. For example, WP Super Cache caches the entire page to the hard disk and directly accesses the static HTML file next time, allowing the server to directly bypass PHP and save CPU time. Batcache will store the entire page in memory as an object. I personally recommend using Memcached enough.

Memcached will store WordPress objects in memory. The server’s memory is large enough, the reading and storage speeds are fast enough, and the memory cache hit rate is greater than 97%. In addition, after our WordPress program has been optimized, the number of queries on each page is generally about 2, so the entire website is very efficient. The homepage even has 0 SQL, and the page generation only takes 0.0013 seconds.

The WPJAM Basic plug-in has integrated Memcached. After downloading WPJAM Basic, copy the object-cache.php file in the wpjam-basic/template/ directory to the wp-content directory.

WordPress program optimization

WordPress program optimization is based on the WordPress Object Cache mechanism to optimize WordPress plug-ins and themes. The main experiences are as follows:

Only use necessary WordPress plug-ins. Installing too many WordPress plug-ins can easily cause performance problems.

Download WordPress themes from regular sites, so that the quality and safety of the downloaded themes can be guaranteed. We recommend the Autumn and Honey themes released by xintheme and me. Home Page 0 SQL has been implemented.

WordPress themes and plug-ins try to use template functions, because WordPress template functions have been prepared in WordPress Object Cache if possible. For example: the two functions get_the_terms and wp_get_object_terms have basically the same functions, but get_the_terms fetches data directly from the object cache without querying, while wp_get_object_terms fetches data from the database every time.

If you must directly query the database for WordPress plug-ins and themes, please prepare an Object Cache, use wp_cache_set to save the query results to the Object Cache, and use wp_cache_get to obtain them directly next time.

WordPress Performance Optimization Service

To summarize: To optimize WordPress, first download and install the WPJAM Basic plugin. Then choose a good server and hosting provider, optimize the WordPress program, and use Memcached for caching.

WordPress is actually very efficient. Coupled with the flexibility and powerful functions of WordPress itself, WordPress is definitely a very good choice for building various websites, so I always use WordPress to build websites.

For more WordPress technical articles, please visit the WordPress Tutorial column!

The above is the detailed content of How to optimize WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1248
24
How to adjust the wordpress article list How to adjust the wordpress article list Apr 20, 2025 am 10:48 AM

There are four ways to adjust the WordPress article list: use theme options, use plugins (such as Post Types Order, WP Post List, Boxy Stuff), use code (add settings in the functions.php file), or modify the WordPress database directly.

How to build a website for wordpress host How to build a website for wordpress host Apr 20, 2025 am 11:12 AM

To build a website using WordPress hosting, you need to: select a reliable hosting provider. Buy a domain name. Set up a WordPress hosting account. Select a topic. Add pages and articles. Install the plug-in. Customize your website. Publish your website.

How to change the head image of the wordpress theme How to change the head image of the wordpress theme Apr 20, 2025 am 10:00 AM

A step-by-step guide to replacing a header image of WordPress: Log in to the WordPress dashboard and navigate to Appearance >Theme. Select the topic you want to edit and click Customize. Open the Theme Options panel and look for the Site Header or Header Image options. Click the Select Image button and upload a new head image. Crop the image and click Save and Crop. Click the Save and Publish button to update the changes.

What are the plugins for wordpress blocking ip What are the plugins for wordpress blocking ip Apr 20, 2025 am 08:27 AM

WordPress IP blocking plugin selection is crucial. The following types can be considered: based on .htaccess: efficient, but complex operation; database operation: flexible, but low efficiency; firewall: high security performance, but complex configuration; self-written: highest control, but requires more technical level.

How to view the front-end of WordPress How to view the front-end of WordPress Apr 20, 2025 am 10:30 AM

You can view the WordPress front-end by logging into the dashboard and switching to the View Sites tab; automate the viewing process with a headless browser; installing the WordPress plugin to preview the front-end within the dashboard; viewing the front-end via a local URL (if WordPress is set locally).

How to import the source code of wordpress How to import the source code of wordpress Apr 20, 2025 am 11:24 AM

Importing WordPress source code requires the following steps: Create a sub-theme for theme modification. Import the source code and overwrite the files in the sub-topic. Activate the sub-theme to make it effective. Test the changes to make sure everything works.

How to cancel the editing date of wordpress How to cancel the editing date of wordpress Apr 20, 2025 am 10:54 AM

WordPress editing dates can be canceled in three ways: 1. Install the Enable Post Date Disable plug-in; 2. Add code in the functions.php file; 3. Manually edit the post_modified column in the wp_posts table.

How to import wordpress templates How to import wordpress templates Apr 20, 2025 am 10:18 AM

WordPress templates quickly create professional websites. The steps to import a template include: select and download the template. Log in to the WordPress dashboard. Select Theme from the Appearance menu. Click "Add New Theme". Click "Upload topic" and select the downloaded template .zip file. Click "Install Now". Click the "Activate" button. Customize the templates through the Customize menu.

See all articles