(Save space) When managing the website, the size of the entire website source code contributes very important to operating the website for a long time in the future. For example, if the total site size is low, moving the website to other servers is easier, or the data backup is fast without problems. On the contrary, the capacity is too high compared to the actual size of the website will cause many difficulties, especially the backup will be much harder.
However, I do support for how many times many of you do the website without thinking about optimizing the source code in the right way so there are many cases where the website is not much data that the total content Reached up to a dozen GB. In this article I will share a little about what to know and should do with the website to save space but still ensure does not affect the operation of the website.
OPTIMIZE IMAGES BEFORE UPLOADING
WordPress has a powerful image manager and I encourage people to upload photos directly to the host of the website for us to reuse or manage, on the one hand also make their images more secure than the. upload to other image hosting services.
However, not every image we upload on the website that need to be optimized before upload. Assuming your image has a resolution of up to 2k, 3k (maximum width) but actually users on the site do not need that, because if the content width on the website is only 800px, your image No matter how sharp it is, it only shows 800px and you want to see the full click on it, but this is only for high quality websites like photography websites, wallpaper. With website sales, the image should only have a maximum width of 1000px because that is enough for customers to view the product, if it is too slow then the website is really losing visitors than the image. small.
References : Optimized images for the website
Next is sometimes the image size is too high compared to the quality of it needed to display on the website. So before uploading you should reduce the image size properly, reduce the capacity sometimes image quality will hardly notice the difference with the naked eye so you do not need to worry. You can install the EWWW Image Optimizer, WP Smush plugin or more, invest $ 5 / month using Kraken as yourself to optimize images when you upload to the website.
And finally take control with the image file itself born of WordPress, but sometimes we do not need to, how to manage photos spontaneously and deleting images are not used you can view articles Management Treat your WordPress image as a full set .
DO NOT SAVE THE BACKUP ON THE HOST
Backup website data for the purpose of restoring your website data when the data is corrupted or the current host has problems can not access but need to move the website data through another host. So then we save the backup on the host itself is running the site is almost nonsense, but also dangerous to waste the host.
You should keep these backups in safe places like cloud storage services such as Dropbox, Google Drive or Amazon S3 (recommended) because your computer is not sure it is safe and stable. More than the host, the other great service is that they are very reputable and almost impossible to interrupt.
Do not think that when backing up we will download the backup and upload to the other services, time consuming. You can use the BackWPUp plugin or BackupBuddy to back it up and upload it yourself to the other hosting services as quickly as possible.
CHECK LOG ERROR AND DO NOT LOG WHEN NOT NEEDED
In addition to backup, log files or log access (host log) on the host is the main culprit of the resource consumption of the host. For the error log website, we sometimes do not need to save the log continuously because there is always need to see log error, but only when debug to find fault or patch will need to pop up. If you do not want the webserver to log the error log on the website then simply add the following to wp-config.php (preferably to the top, below
Besides please make sure that you have set
falsein wp-config.php to disable debug mode. And delete the .log or error_log file on the host if there is.
For access logs we can not turn off using Shared Host, but if we use our own server, we can disable it by deleting the access log statement in the webserver setup file.
CHECK THE WP-CONTENT DIRECTORY
Many plug-ins save unnecessary data in the wp-content directory such as plugin log files or temporary files. In the wp-content directory, except for the cache directory and the image, we should not add anything here.
DO NOT SAVE VIDEO OR COMPRESSED FILES
If you have a lot of video sites, it's best to upload them to YouTube if you do not need to hide your videos. Or if your video needs to pay for a new viewer, the more you should not upload to the host running WordPress because regular players can be easily downloaded through the support software like Internet Download Manager is the typical example, instead. You can use Wistia or SproutVideo to prevent download.
As for the compressed files for others to download, you can upload to hosting services such as Mega.co.nz, Fshare or paint to find a cheap server service but have high hard drive to upload and For users to download there.
Database also uses the hard drive on the host to save, which means that the larger the database, the more storage capacity, and when backing up the entire website it will save to the backup so the capacity will be huge. I have just witnessed a WordPress site using Woocommerce with a database up to 4GB, which has a waste of 3.7GB, then this is completely true.
Make sure you have optimized the wp_options table of the database so that it does not contain a lot of junk data, and you should also manually clean the database periodically so that your data is clearer. The longer your database is, the harder it is to optimize.
If you use WooCommerce then check the wp_options table is large, if so, because it contains many unused session and transient, run the following command several times to clean up.
If your database is large then you should run this command many times, because you should limit it to delete every 20000 lines to avoid stuck host by MySQL processing too much.
Currently the database of thachpham.com is exactly 32MB, I have not deleted the data not used in wp_postmeta anymore. Say so so you understand that WordPress does not eat as many databases as you think.
The content above I have also seen the optimization of the website size is not too complex as we think, but the benefits of it is very large, because you certainly will not be able to save the website on. Same with a host for a long time that may need to move to another place, and light data will help us do things faster and simpler.