FV Gravatar Cache
FV Gravatar Cache
Description
There’s one problem with Gravatars. They are very slow to load. Each page with comments on them makes one call per comment to the Gravatar server. While a single call takes only a 100ms, on a page with hundreds of comments, we are talking about major slowdowns. Page loads can take 20 seconds and more.
This plugin solves this problem by:
-
caching gravatars with WordPress cron job..
-
caching gravatars on comment submission
-
maintaining a single copy of the default gravatar instead of downloading it again and again for all the email addresses with no gravatar associtated
Installation
You can use the built in installer and upgrader, or you can install the plugin
manually.
After installing, make sure you visit the plugin settings to make sure the plugin works correctly. You will see a check if the cache directory is writable and you will have to set the gravatar size (plugin also uses autodetection mechanism, which might come handy).
Faq
Hit the “Empty Cache” button to clear the cache database and clear out the cache directory by hand (you can see the path at the very top of the Settings screen). Then hit the “Run Cron Now” button, it will refresh a couple of gravatars, so you can check the cache directory again, to see if it’s filling up correctly. “Current Cron offset:” will increment, so you can track the progess and see how the cron is running. You can also turn on “Debug mode” and check log.txt afterwards.
These types of gravatars are not currently supported. Drop us a note and we might add this feature in next release.
You can turn edit your template to turn off the FV Gravatar Cache just when needed, add this code right before that section in your WordPress template php file:
<?php global $FV_Gravatar_Cache; remove_filter( ‘get_avatar’, array( &$FV_Gravatar_Cache, ‘GetAvatar’ ) ); ?>
In case you need the FV Gravatar Cache running later in the template, just bring it back with:
<?php global $FV_Gravatar_Cache; add_filter( ‘get_avatar’, array( &$FV_Gravatar_Cache, ‘GetAvatar’ ) ); ?>
If you selected empty gravatar in wp-admin -> Settings -> Discussion, then it’s ok. Otherwise try to resave the options and it should appear.
Reviews
Gravatar Cache boosted my site's performance scores
By roam92 on January 11, 2021
Not working
By grafis (Snackmaster) on February 8, 2020
Only caches a few out of each hundred
By christinaleans on March 22, 2019
Database Junk
By Gulshan Kumar (thegulshankumar) on October 6, 2017
Highly recommended
By (TheAnalyzer) on August 15, 2017
Good but need more
By gokuldeepak on September 3, 2016
This plugin works well and increases speed but the problem is it only caches images for the registered users. I want to cache for every user who comments on my page. (They Don't need to login to comment on my website instead giving their name and email id is enough)
Is it working?
By semperaye on September 3, 2016
Not sure if it's working, the settings are showing no gravatar's in cache.
Reduce my load time and improved my performance scores
By xantius on September 3, 2016
This plugin was super helpful for reducing the amount of requests my most popular web pages made (pages with over 150 comments) and helped clean up my scores on website analyzers. Thanks!
Works like a charm!
By robintel on September 3, 2016
This is just what I needed, simple to use, fire and forget!
Changelog
0.5
- Tested up to WordPress 6.8
- Fix PHP warnings before settings are saved
- Fix settings page access to be admins only
- Added uninstall procedure to remove files and database table
- Security: Added nonces for settings page list of avatars
- Security: Added permissions check for settings saving as an addition to the existing nonce
- Security: Use SHA-256 hashing for cached file names which is stronger than MD5
0.4.8
- Fix for avatar caching for comments without email address (rare cases)
0.4.7
- Fix for PHP timeout when Gravatar server unreachable during comment posting
- WordPress 5.4 compatibility checked
0.4.5
- Security fixes
- WordPress 5.3 compatibility checked
0.4.3
- Fix for WP Rocket CDN rewrite
0.4.2
- Fixing PHP notices
0.4.1
- added retina alternative for default gravatar
- fixed retina images srcset
- retina images downloading enabled by default now
0.4
- changed images directory to wp-content/uploads/fv-gravatar-cache/
- added support for retina images
- added cache purge after update if cache directory is set to default
- added protocol independent urls
- added paging for gravatars into settings screen
- fixed cron offset reset
- fixed perfomance issues
- fixed PHP warning
- fixed security issue for debug log functionality
- fixed images – adding .png extension as default
0.3.8
- fix for PHP warnings by Thomas van der Westen
0.3.7
- Added admin_notice warnings
- Added a check if the cache directory is empty when the cached data is present in database – to prevent 404 errors for cache gravatars
- Improving conditions, improving checking of values after submit
0.3.6
- Fix for PHP warnings
- Fix for cache disappearing after plugin upgrade (applies to users who didn’t changed the cache directory)
0.3.4
- Cron job limited to 2 seconds execution time
0.3.3
- Bugfix for empty gravatar in cache
0.3.2
- Bug fix for WordPress 3.1 admin bar
- Bug fix for blank gravatar
0.3.1
- Better detection of missing/default gravatars
0.3
- First public release
0.2
- Added cron support
0.1
- Works only for logged in users