Cache Gravatar makes WordPress sites load faster

Cache Gravatar makes WordPress sites load faster

If you don't already know, the Gravatar in the comments section of your WordPress website will be downloaded from the Gravatar.com server, not from your host. Therefore, even if your site is hosted on a server in the EU, it will still be affected by an undersea cable problem, especially in the case, the article has many comments. So how to solve this problem to increase the loading speed of your WordPress website? The main solution is to cache Gravatar on the host. In today's article, I will show you in detail how to do that.

Why does Gravatar affect web loading speed?

As mentioned at the beginning of the article, Gravatar is downloaded directly from Gravatar.com's server, so you cannot compress to reduce the size or set the cache time on the web browser for them. Each Gravatar is an image, so the more Gravatars a page has, the more requests it receives and the slower it loads. Even if your website uses a host located in EU, Gravatar is still downloaded from servers located abroad. That is, the loading speed of the elements on the website will not be the same. You will need to cache Gravatar on your host to minimize their impact on web loading speed.

Cache Gravatar with LiteSpeed ​​Cache plugin

If you are using the LiteSpeed ​​Cache plugin on your website then things will become very easy.

1. All you need to do is access LiteSpeed ​​Cache -> Page Optimization -> [6] Localization -> Set up as shown below.

Cache Gravatar makes WordPress sites load faster cache gravatar

Inside:

Gravatar Cache: you leave it in the ON state to enable it.
Gravatar Cache Cron: you leave it in the ON state so that the plugin automatically refreshes the caches after a set period of time.
Gravatar Cache TTL: Gravatar cache time, in seconds. The recommended value is 604800 seconds equivalent to 1 week.
After the setting is complete, click the Save Changes button to save it.

2. Go to a page containing Gravatar, right-click on any Gravatar, and select Inspect. If you see a link in the form .../wp-content/litespeed/avatar/..., it means you have successfully enabled the Gravatar cache feature.

Cache Gravatar with FV Gravatar Cache plugin

1. First, you need to install and activate a plugin called FV Gravatar Cache (download).

2. Go to Settings -> Discussion -> Default Avatar -> Choose the default Gravatar which is Mystery Person, Blank, Gravatar Logo, or your custom Gravatar. Absolutely do not choose the remaining forms (with the word Generated).

3. Access a page or post containing comments with the default Gravatar. Right-click on the default Gravatar and save it to your computer. Check how many pixels it is. For example, 100 x 100 pixels, in step 5, you will set the same size. Rename the image file to default (with .png format).

4. Access the /wp-content/plugins/fv-gravatar-cache/images/ folder via FTP/ SFTP or cPanel/ DirectAdmin's File Manager. Delete the default.png file contained in the images folder and upload the default.png file you created in step 3.

5. Next, go to Settings -> FV Gravatar Cache -> Set the necessary parameters for the plugin.

Cache Gravatar makes WordPress sites load faster cache gravatar2

Inside:

Custom Cache directory URL: it's best to leave it blank by default to avoid errors.
Gravatar Size: the size for the Gravatar you want to cache.
Daily cron: run a daily cron job to refresh caches.
Click the Save Changes button to save the settings when done. Click on the Run Cron Now button to start the plugin.

6. Click the show button in the Cache information section, you will see a list of Gravatars (corresponding to emails) that have been cached on the host.

It looks like this.

Cache Gravatar makes WordPress sites load faster cache gravatar3

Pretty simple, isn't it? Good luck!

During the first load of a page or article, it often takes more time to cache Gravatar, so the loading speed is not fast. In subsequent downloads, the loading speed will be greatly improved because Gravatar is already cached.