How to accelerate the Gravatar Avatar cache

Source: Internet
Author: User
Tags md5
Gravatar portraits are used most often, but Gravatar Avatar servers are abroad, and the speed is definitely affected. What if Gravatar portraits are cached quickly?
Most of the images on the Internet are locally cached, and then the local Gravatar Avatar cache is used to speed up the process.
But this time I used another method to speed up without increasing the load on my server, because there is a free Qiniu, which uses the synchronous Image function of Qiniu to synchronize the Gravatar profile picture website, then, change the addresses of all Gravatar pictures to the addresses of Qiniu.
 
Usage:
1. Go to Qiniu to apply for an account. Address: http://www.qiniu.com
Promotion registration address: https://portal.qiniu.com/signup? Code = 3lkin4af40swi (I hope you can use this registration to give me more space. Thank you)
2, create a space, Qiniu will allocate a Level 2 domain name, open the space of the "space settings" --- "image storage", fill in the Gravatar profile of the official website address (http://www.gravatar.com)
3. Test the effect of the Avatar after the Qiniu cache
Because I am using emlog, the connections created by the Gravatar Avatar are generally the following connections.
Test connection: http://www.gravatar.com/avatar/6016bea8a1116741c739ff17f8062776? S = 40 & d = mm & r = g
Through the Seven cattle bound domain name (here I have bound their own domain name): http://avatar.myxzy.com/avatar/6016bea8a1116741c739ff17f8062776? S = 40 & d = mm & r = g
Found that can be accessed normally, but the Avatar parameter is gone, jump directly to the http://avatar.myxzy.com/avatar/6016bea8a1116741c739ff17f8062776
4. Use the IMG Image processing function to customize the image size.
Qiniu backend "data processing" --- "style separator", set to "/", and then "create image style ".
Set the style name by yourself, for example, "thum32"; "scaling mode": specify the width and height for scaling, and set the width and height to 32; "output format" is consistent with the source image; you can choose "image quality", such as 100%.
Test http://avatar.myxzy.com/avatar/6016bea8a1116741c739ff17f8062776/thum32 after setting
You can output a Gravatar avatar of the specified size. You can set multiple image styles, but it is best not to set it to 80 PX in width or height.
 
Some other problems:
1. The Gravatar profile of other parameters cannot be output;
2. If you change the Gravatar Avatar, the Gravatar avatar in the Qiniu cache will not be automatically updated. You need to manually update it. (You can clear the content of the synchronization space after a while)

Demonstration effect: you can see the Gravatar Avatar effect on this site.

Emlog, directly modify the parameter delibfunction. base. php.

The code is as follows: Copy code

Function getGravatar ($ email, $ s = 40, $ d = 'mm', $ g = 'g '){
$ Hash = md5 ($ email );
$ Avatar = "http://www.gravatar.com/avatar/?hash? S = $ s & d = $ d & r = $ g ";
Return $ avatar;
}

Change
Function getGravatar ($ email, $ s = 40, $ d = 'mm', $ g = 'g '){
$ Hash = md5 ($ email );
// $ Avatar = "http://www.gravatar.com/avatar/$hash? S = $ s & d = $ d & r = $ g ";
$ Avatar = "http://avatar.myxzy.com/avatar/$hash/thum$s ";
Return $ avatar;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.