With the use of website construction more and more long, our site may use more and more pictures, CSS and JS files, although these are not small size, but if the number of requests, the size of these files added up is a considerable size! Moreover, if your page pictures or JS and other files more, and your website access speed is not too fast, it will seriously affect the speed of your site access!
Today we recommend a static file storage cloud storage: Seven Cow cloud storage (click here), it provides free use of cloud storage features: Ordinary users can use free 10GB of storage space per month, free monthly download traffic to 10GB, monthly free Put/delete 100,000 requests and free get 1 million requests per month. For the normal site, fully enough for us to use, we can all of the site's static files are stored in seven cow cloud storage. This is great help if you have traffic restrictions on your website, and the files stored in the Seven Cow cloud server are very fast! Here are the number of traffic and get used for my Site December 2014:
As you can see, in December, I used a total of seven cow cloud storage of 10.308GB of traffic, the average number of times a day to use 340.511mb;get 808,458 times! This has reduced a significant portion of the request to my server.
It says so much, how to use seven cow cloud storage? If you are a WordPress user, you can use my love boiled fish made of seven cow image storage WordPress plug-in, which integrates a lot of the use of seven cows, but the site of the plug-in more, there will be a lot of problems, such as if you use the site of the seven image storage WordPress Plug-ins and Syntaxhighlighter plug-in words, then congratulations, your syntaxhighlighter will not be able to use! I haven't seen anyone solve the problem at the moment.
In fact, we can add some code in the site itself, it can automatically upload some static files inside our site to seven cow cloud storage inside, and our site used to the address of these static files into seven cattle address can be, the code is as follows:
if (!is_admin ()) {//access the blog foreground only calls Add_action (' wp_loaded ', ' Iteblog_qiniu_ob_start '); function Iteblog_qiniu_ob_start () {ob_start (' iteblog_qiniu_cdn_replace '); } function Iteblog_qiniu_cdn_replace ($html) {//here is replaced with your blog domain name $local _host = "Http://www.ite Blog.com "; $qiniu _host = "http://iteblog.qiniudn.com"; Extensions of files requiring CDN acceleration (using | delimited) $cdn _exts = ' Js|css|png|jpg|jpeg|gif|ico|swf|eot|woff|ttf|svg| PNG '; $cdn _dirs = ' wp-admin|wp-content|wp-includes|avatar|pic '; Directory (using | delimited) $cdn _dirs = Str_replace ('-', ' \-', $cdn _dirs); if ($cdn _dirs) {$regex = '/'. Str_replace ('/', ' \ \ ', $local _host). ' \ \ (('. $cdn _dirs. ') \/[^\s\?\\\ ' \ ' \;\>\<]{1,}. ('. $cdn _exts. ')) ([\ "\\\ ' \s\?] {1}) /‘; $html = Preg_replace ($regex, $qiniu _host. '/$1$4 ', $html); } else { $regex = '/'. Str_replace ('/', ' \ \ ', $local _host). ' \ \ ([^\s\?\\\ ' \ ' \;\>\<]{1,}. (‘ . $cdn _exts. ')) ([\ "\\\ ' \s\?] {1}) /‘; $html = Preg_replace ($regex, $qiniu _host. '/$1$3 ', $html); } return $html; }}
Put the above code in your site's functions.php file, save it, so that it will automatically put your site static files last time in your seven cow storage space inside. and replace the static image of your site with the address of seven cattle. To the current location, almost all of the static files on my website are stored with seven kn cloud.
Seven Qiniu storage is very powerful, we can also use the relevant API seven to crop the image, such as the following using the seven Bull API to cut the size of the image to 185 high 110 size picture
http://iteblog.qiniudn.com/wp-content/themes/yusi2.0/img/pic/5.jpg?imageView/1/w/185/h/110
。 For a detailed API see the seven KN development documentation:
http://developer.qiniu.com/docs/v6/api/reference/fop/image/imageview2.html
。
If you want to add watermark to the picture, you can also use seven of the API provided by the Ox, you can add image watermark, text watermark, such as my blog using the text watermark:
http://www.iteblog.com/p ic/qiniu.png?watermark/1/image/
aHR0cDovL2l0ZWJsb2cucWluaXVkbi5jb20vcGljL2xvZ28ucG5n/dissolve/100/gravity/SouthEast/dx/20/dy/20
。 Where ahr0cdovl2l0zwjsb2cucwluaxvkbi5jb20vcgljl2xvz28ucg5n is your watermark text URL Security Base64 encoding. If it is a picture, it also needs to be converted into a URL-safe Base64 encoding. URL-Safe Base64 encoding is suitable for scenarios in which BASE64 encoding results are delivered in a URL manner. The basic procedure for this encoding is to encode the content in Base64 format as a string, then examine the result string, replace the Plus + + in the string with an underscore-and slash/change to underscore _, while the tail remains filled with equals =.
For more information, please see the Seven Cow development documentation
http://developer.qiniu.com/docs/v6/api/overview/appendix.html#urlsafe-base64
This blog post except special statement, all are original!
Respect the original, reproduced please specify: Reproduced from the past memory (http://www.iteblog.com/)
Website Construction: We strongly recommend the use of third-party cloud storage