Many studies have shown that the most satisfying page load time for users is less than 2 seconds. The long waiting time limit that can be tolerated is probably between 6-8 seconds. If you need to wait 12 seconds, more than 99% users will close the page and leave.
So if you want to provide users with a pleasant experience, try to open your website within 2 seconds.
Problem
We know that the Meteor App after packaging the front-end CSS and JS files even if the compression is about 500KB. This way if you use your own Web server to provide these files load, a problem is very slow, but also consumes more cloud host traffic, which is more expensive than CDN traffic, General Cloud host traffic is CDN traffic 3 to 5 times times the price, or even more expensive, if your configuration is high.
Simple calculation
If your Web server is the most basic of a gigabit bandwidth of 1 MB/s (Note the MB and MB conversions), then even a person visiting will have to wait at least 4 seconds to see your home page, two people will become 8 seconds (actually longer). More people is the turtle speed. Even a large water pipe of up to hundreds of people is not worth the visit, and this traffic is generally not worthy of the load balancing technology. It is worth mentioning that the host large bandwidth is very expensive.
If your server is based on traffic charges, then about 1 yuan/GB, depending on your server provider and region. But using a CDN generally at 0.3 yuan/GB, you can save 70% of the traffic cost. The peak traffic for a single cloud host is also limited, certainly not as distributed nodes of the CDN.
So the use of CDN has a great advantage in both speed and economy.
Workaround
The workaround is simple, just use an external CDN service, load a Meteor package, and add a single line of configuration to the deployment. You don't have to write any extra code or upload files yourself.
CDN Services
First you have to have a CDN service. Here is an example of the seven cows I use. Seven cows have a monthly free 10GB plan, should be able to meet a lot of small applications, or testing purposes. You can use Github or other ways to log in to seven cows.
First you need to create a new resource, similar to the Amazon S3 Bucket. Specifically, object storage, add resources. After creating the resource, select the mirrored storage. Then fill in the image source with your website address. For example
Mcdn
When you're finished, you'll get a seven-cow-generated test domain name, similar to xxxxxx.bkt.clouddn.com. Of course you can also use your own domain name bindings. Make a note of the domain name and use it later.
Using the METEOR-CDN Package
The Code and documentation for this package are in HTTPS://GITHUB.COM/ZXH930508/METEOR-CDN. Its main function is to change the domain of the packaged CSS and JS files to the CDN address you specify. If there are no Cdn_url settings in the environment variables, then the program will not change.
Installation
Meteor Add Nitrolabs:cdn
Run
One way is to specify the address of the Cdn_url at run time
Export cdn_url= "http://xxxxxx.bkt.clouddn.com" && Meteor
or env plus Cdn_url in your MUPX configuration.
mup.json{ //Normal MUP settings //... Configure Environment "env": { "PORT" : " cdn_url" : "http://xxxxxx.bkt.clouddn.com", "Root_url" : "Http://www.mysite.com" }}
After running in one of these two ways, your website will fly up. You can use the Chrome Developer Tools Network page to view the load times for individual files.
Conclusion
Is the load situation of the JIANBO.IM Web site without using the cache. Meteor Packed compressed 419 KB Meteor_js_resource Only need 98 MS Load, the entire initial markup load took 682 Ms.
Network
Of course there are many ways to improve the loading speed of web pages, but this method is simple and effective, can meet many Meteor app scenarios, can make your Meteor app in the less expensive cloud host network conditions to handle more user access.
What else is attached to the mirrored bucket, which is what the file is speeding up. You can see JS, CSS and some characters and other information files. Robots.txt is to tell the search engine whether to ingest and handle mirroring conflicts. There are two sets of CSS, JS files because I build two times, each time the file name is different. This also ensures that the user accesses the updated CSS and JS files after each modification of the source code.
Buckets
Original link: http://www.jianshu.com/p/98388e50ab0a
Easily reduce the first screen load time of the Meteor App