In this tutorial we will give you some tips on how to improve the speed of your WordPress site. Having a fast site is essential if you want to provide your visitors with a good user experience, and, at the same time, rank better in search engines such as Google and Bing, as they take into account the speed of page loads at the time. to sort the results.
Enable dynamic caching
Adding a cache (think of it as “preloading” data) for dynamic content has a significant effect on the speed of your WordPress site. Here You can find a comparison between 6 caching plugins for WordPress app users.
Enable gZIP compression
This is how we can significantly reduce the size of the data being transferred (sometimes to as much as 10% or less than the original file). The easiest way to enable gZIP compression for your images, CSS and JS files is to add these lines to your .htaccess in the root folder of your WordPress installation:
## ENABLE GZIP COMPRESSION ##
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
## ENABLE GZIP COMPRESSION ##
Note: Before making changes to the .htaccess, always keep a backup somewhere on your computer.
Use a CDN
Content Delivery Networks (CDNs) are links between servers that store copies of your site's static content (images, libraries) on all of their location nodes. So, an individual in Madrid will access your site via a server located in Spain (perhaps in Madrid itself), while an Argentinian will access your content with the server closest to his region. Then, the data is sent from the server closest to the user, instead of from your hosting provider's main data center.
For more information on this, see our plans from Cloudflare CDN.
Optimize your images
Images are an essential part of the aesthetics of any website, but it is even more important to have them optimized. In most cases, on sites with multiple images it is the images themselves that slow down data loading the most, especially since an unoptimized image can weigh over 100kb, or much more.
Images are measured by size and weight. The size refers to its dimensions in pixels (example, 500px wide by 200px tall), while the weight it is merely how much the file is in kilobytes.
Use images with the appropriate size and weight. This implies, among other things, do not upload large images (for example, photos that are 1000 pixels wide) by letting WordPress scale them to present them at smaller sizes. Make sure your photos and images are never larger than the actual size shown on the screen (remember, WordPress can display a giant image in a small area of the screen, shrinking your virtual presentation with a simple HTML command; To check this, just load a site with a desktop computer, position the mouse pointer over the image, right click and choose "view image". If when you view the image alone, it appears larger than the one you were viewing before, then that image is the wrong size for actual display.)
And now Let's talk about the weight in kb: An option to significantly reduce the weight of the images that you upload to your media library, and automatically, is by installing the smush-plugin.
Smushing compresses the images so that they weigh less, altering little or nothing their quality, but, in addition, it will remove from your JPGs (and other formats of bitmaps) certain data hidden but present: the date of creation of the image, the camera used for the photo, the gps coordinates, the angle of a lens and others are examples of a lot of information that hides a simple bitmap And we didn't even know it existed.
If possible, use sprites for your themes, and no, we do not mean the soda. The use of sprites is a CSS technique that uses a single image to display multiple layout elements on pages. This way, instead of loading dozens of small images (making requests to the server for each one), the images will be opened with a single request. sprites is a good etiquette when choosing your theme, so keep it in mind when looking for or buying themes.
Take advantage of browser caching
Leveraging browser caching means you can specify how long your visitors' web browsers will store your site's images, CSS, JS, and flash files in their own caches. This is useful for the recurring visit, and in practical terms means that a web browser will not re-download certain information from the server when it already pre-exists on your hard drive. Specifying the cache time, or manipulating it in your favor, is an excellent way to stipulate and/or lengthen the number of days that any browser will keep these files. If you don't, browsers delete images at a default time, but if you know that certain content on your site doesn't change for months (eg, the cover image of a note), then it's useful to trade over time. of the cache, to extend it as much as possible.
You can add these lines to the .htaccess to enable this manipulation technique.
## LEVERAGE BROWSER CACHING ##
ExpiresByType image/jpg “access 1 year”
ExpiresByType image/jpeg “access 1 year”
ExpiresByType image/gif “access 1 year”
ExpiresByType image/png “access 1 year”
ExpiresByType text/css “access 1 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType image/x-icon “access 1 year”
ExpiresDefault “access 2 days”
## LEVERAGE BROWSER CACHING ##
Optimize your WordPress database
It is good practice to optimize your WordPress database from time to time. You can think of this as running a disk defragmenter on your local hard drive (and if you don't know what that is, don't worry). There are many alternative ways to optimize your database. If the hosting company you hire allows you to use the cPanel administrator, then you already have a very easy tool to achieve it: PHPmyAdmin (and now we are going to explain step by step how to do it with this tool). But if you don't have cPanel with your hosting plan, you can install plugins to achieve it, and a good example is admin, a very easy to use plugin with on-screen instructions.
Optimizing my wordpress database with PHPmyAdmin
Enter your address cPanel (probably yoursite.com/cpanel either cpanel.yoursite.com). Once inside, look for the PHPmyAdmin icon.
Once inside the phpMyAdmin interface, select the database that you have created with your WordPress installation. In this case, "infoloco_infoDB" was placed as an allegorical name.
You will see a list with all the tables. Scroll to the bottom of them to find the “select all” and “optimize table” options. Look at the screenshot to guide you.
The moment you click on “optimize the table”, the process will automatically begin. Do not panic: depending on the size of your website, it can take between seconds and a few minutes.
When the process is finished, you will see the message “Your query was executed successfully”. And that's it!
You already have a lot of information and tools to start optimizing the content of your site, gain speed and climb positions in the search results. Let's do it!