Saving space for WordPress website

Saving space for WordPress website

When managing a website, the size of the entire website's source code makes a very important contribution to the operation of that website in the long run in the future. For example, if the total website capacity is low, then moving the website to other servers is easier, or backing up data is also fast without any problems. In contrast, the capacity is too high compared to the actual capacity of the website will cause a lot of difficulties, especially the backup will be much harder.

However, I have been a supporter for so long. I see many cases of people making websites without thinking about optimizing their source code properly, so there are many cases where the website does not have much data but the total content. back up to tens of GB. In this article, I will share a little about what to know and should do with the website to save space while ensuring not affecting the operation of the website.

Saving space for WordPress website saving space Saving space for Wordpress website input output t20 NQVA9E min

Optimize images before upload

WordPress has a powerful image manager and I encourage people to upload images directly to the website host for us to reuse or manage, on the one hand also helps our images to be more secure. Upload to other image hosting services.

However, not every image we upload to the website, we almost need to optimize before uploading. Let's say your photo has a resolution of up to 2k, 3k (maximum width) but actually users on the website do not need to, because if the width of content on the website is only 800px, your image no matter how sharp it may be, it only displays 800px and if you want to see it all you have to click, but this is only for websites that need high-quality images such as photography websites or wallpapers. For sales websites, the image should only have a maximum width of 1000px because that is enough for customers to see the product if it is too large, the website loads very slowly and then it is really losing customers rather than photos. small.

Next, sometimes the image size is too high for it to display on the website. So before uploading you should reduce the image size appropriately, reducing the size sometimes the image quality will be difficult to notice the difference with the naked eye so you do not need to worry. You can install the EWWW Image Optimizer, WP Smush, or play more than investing $5/month using Kraken as yourself to optimize the image when you upload it to the website.

For images optimizing, please  read:

Optimize images for website

And finally, take control with the self-generated image files of WordPress that we sometimes do not need to use, on how to manage the self-generated images and delete unused images, you can view the admin article. image management on your entire WordPress site.

Do not store your backups on your host server

Website data backup with the purpose is to restore your website data when the data is corrupted or the current host has problems inaccessible but needs to move the website data to another host. So then we save the backup on the host that is running the website is almost pointless but dangerous and consume the capacity of the host.

You should keep these backup files in really safe places like cloud storage services like Dropbox, Google Drive or Amazon S3 (recommended) because your computer is not necessarily safe and stable. More than their host, the other big service is that they are already very reputable and almost uninterrupted.

Do not think that when backing up, we will download the backup to your computer and upload it to the other services, which is very time-consuming. You can use the BackWPUp or BackupBuddy plugin to backup and it lends itself to the other hosting services as quickly as possible.

Check Error Logs and should not log when not needed

In addition to backing up, corrupted log files or access logs on the host are the main culprits for the host's resource drain. For website error logs, we sometimes do not need to log continuously because it is not always necessary to view the error log, but only when debugging to find errors or patches, it will need to turn on. If you don't want the webserver to store error logs on your website, simply add the following to wp-config.php (preferably up, below <?PHP ).


Besides, make sure you have set WP_DEBUG to false in wp-config.php to disable debug mode. And please delete the .log file or error_log on the host if any.

For the access log, we can not turn off if using Shared Host, but if using a private server, it can be turned off by deleting the access log declaration line in the webserver setup file.

Check the 'wp-content' directory

There are many plugins that save unnecessary data in the wp-content directory like plugin log files or temporary files. In the wp-content directory, except the cache and images folder, we should not save anything here.

Do not store videos and compressed files

For websites with lots of videos, it's best to upload them to YouTube if you do not need to hide your videos. Or if your video needs to be paid for a member to watch, it should not be uploaded to a host running WordPress because normal players can easily be downloaded through supporting software such as Internet Download Manager. You can use Wistia or SproutVideo to prevent downloading.

As for the compressed files for others to download, you can upload them to storage services such as, Fshare or paint to find a cheap server service but have a high hard drive to upload and for users to download there.

Optimize database

The database also uses the hard drive on the host to save, which means the bigger the database, the more storage space it will use, and when backing up the entire website, it will save to the backup, so the volume will be very large. I have just witnessed a WordPress website using Woocommerce with a database of up to 4GB and the garbage data is 3.7GB already, this is completely true.

Make sure you have optimized the database wp_options table so that it does not contain a lot of junk data, and you should also manually clean the database periodically to make your data more smoothly. Because the longer you leave it, the bigger the database will become and the harder it will become.

If you use WooCommerce, check if the wp_options table is large, if it is, because it contains many unused sessions and transients, runs the following commands multiple times to clean up.

DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient%') ORDER BY `option_id` LIMIT 20000;
DELETE FROM `wp_options` WHERE `option_name` LIKE ('_wc_session_expires%') ORDER BY `option_id` LIMIT 20000;

If your database is large, you need to run this command many times, because I should limit it to delete 20,000 rows at a time to avoid hosts being frozen by MySQL too much processing.

Currently, the database of this site is exactly 320MB, I have not removed the unused data in 'wp_postmeta' anymore. That said, you will understand that WordPress does not eat as many databases as you think.


Through the content of the above article, I also saw that optimizing the website size is actually not too complicated as we think but its benefits are huge because you certainly will not be able to host the website on. The same host for a long time may need to move elsewhere, and the light data will help us make these things faster and simpler.

-- Saving space for WordPress website --