PHP open-source system-use Minify to optimize website performance

Source: Internet
Author: User
Tags php website website performance

1. Set up a PHP website and complete some basic Image Upload functions and server database operations.
2. Complete adding the actual function example to the static template of the first jquery framework;
Understand and master the use process and mechanism of the sizzle. js framework, and successfully conduct reference experiments on the local Apache server site for self-building.
One or two examples of sizzle. js applications. I have a deep understanding of sizzle. js.
We plan to be familiar with sizzle. js and master complicated functions tomorrow;

 

Learn to use chrome to analyze performance, amd mode.

 

Http://www.cnblogs.com/huangxincheng/archive/2011/12/04/2275988.html

Http://www.dojocn.org/home.php? MoD = Space & uid = 3 & Do = Blog & id = 11

 

Minify is usedPHP5. developed applications improve website performance by following Yahoo's optimization rules. It will merge multiple CSS or JavaScript files, remove unnecessary spaces and comments, perform gzip compression, and set the browser cache header. This article mainly introduces Minify to optimize website performance.


Minify is an application developed with PhP5. It improves website performance by following some yahoo optimization rules. It will merge multiple CSS or JavaScript files, remove unnecessary spaces and comments, perform gzip compression, and set the browser cache header. Minify
The design is very similar to Yahoo's combo handler service, but Minify can merge any JavaScript and CSS files you want to merge.

Generally, the bottleneck of website speed lies in the front-end, and the most critical is the loading speed of resources. However, most browsers have a limit on the number of concurrent requests for a single domain name, therefore, if a page contains many resources, such as CSS and JavaScript files, the loading speed of the website will be significantly reduced. A better way is to access multiple files through one request, this will not affect the previous file maintenance, but will reduce the number of clear resources, Minify is born for it.

The following two figures show a comparison of the website request time before Minify is enabled and after Minify is enabled. We can see that after Minify is enabled, the resource loading time is reduced from 125 Ms to Ms, A total of 50% of the time is saved.



Features:

Merge multiple CSS or JavaScript files into one file to reduce the number of requests and perform Minify

Multiple open-source libraries are used, including jsmin. php, Minify CSS, and Minify HTML.

Server cache (fils/APC/memcache) to avoid unnecessary repeated Processing

If the browser has a resource cache, HTTP 304 not modified is returned.

When multiple files are merged, the URI is automatically generated.

When server cache is enabled, Minify can process hundreds of concurrent requests per second on a general server.

Enable content-encoding: gzip based on the request header. When the server cache is enabled, Minify provides gzipped files faster than the Apache's mod_deflate module.

Install

Download the latest Minify (http://code.google.com/p/minify/downloads/list) and unzip the file to the min folder

Copy the "min" folder to the document_root directory of your website. If you want Minify to work in the subdirectory, check the folder here.

Use

If the website domain name is a http://example.com and Minify is installed under the root directory of the VM, then visit http://example.com/min/, we will see a brief Minify URI builder ", we can enter the file URI to be merged, as shown below

  

After you click Update, the system automatically generates a merged URI:/MIN /? B = JS & F = jquery-a.js, jquery-b.js, jquery-c.js. If you think the URI is too long, you can specify the Group through the configuration file, edit the groupsconfig. php file in the min directory, and add the following content:

Return array ('js' => array ('// JS/jquery-a.js', '// JS/jquery-b.js', '// JS/jquery-c.js '), // relative to document_root );

Then you can use/MIN /? G = Js.

  

When a resource is requested for the first time, Minify merges multiple files, Gzip, removes spaces, comments, and caches the processed results, by default, files are cached. The cached key starts with Minify _ and is modified to min/config. PHP file:

$ Min_cachepath = '/tmp ';



  

In addition to file caching, Minify also supports memcache caching. to modify the min/index. php file, add the following code:

  

Minify supports two debug methods. One is to debug PHP errors through firephp, modify the min/config. php file, and add the following code:

  

Another method is to add flag to the URL for error debugging and add it to min/config. php.



Then you can
Source: http://developer.51cto.com/art/201105/261146.htm

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.