WordPress Load Optimization

Original link: https://www.williamlong.info/archives/6971.html


These days, one of my website servers is often under high load. A WordPress website is installed on it, and when I check the logs, people often crawl wp-login.php. It is estimated that it is a hacker attack, which leads to a large number of database accesses and causes the load to be too high.

WordPress is actually a very common website building tool. It is estimated that many people will use it. I will introduce my solution here.

1. WordPress is static

First, implement site-wide static processing for the WordPress website. The plugin I use is the “super-static-cache” plugin, which can realize the staticization of articles and directories.

However, after using the “super-static-cache” plugin, there will be a redirection problem for directories and tags, that is, it automatically jumps from a directory without “/” to a directory with “/”, although there is no problem in normal browsing, But it is not friendly to SEO. It is better to install another plugin called “permalink-trailing-slash-fixer” to solve the problem of category redirection.

2. Add firewall rules

After WordPress is statically processed, normal users should not access the php file when accessing the website. At this time, add a firewall to the website. It is recommended to use the free cloudflare. In the firewall background – “Security” – “WAF”, add a rule, when the “full URL” contains “php”, the firewall’s “hosted challenge” operation is performed.

The expression is: http.request.full_uri contains “php”

I actually operated on the host, and after deploying the firewall rule, I found that the overall server load returned to normal immediately. I checked the firewall background, and the CSR (question resolution rate) is 0, which means that all of them are captured by the machine, and they are all filtered out, and the effect is very good.

If you also encounter similar problems, you can try to use the above method to optimize it, and you may be able to quickly solve the problem of high load.

This article is reprinted from: https://www.williamlong.info/archives/6971.html
This site is for inclusion only, and the copyright belongs to the original author.