Home> php教程> PHP开发> body text

Using the apache module under Windows to merge multiple js and css to improve web page loading speed

高洛峰
Release: 2017-01-04 10:39:31
Original
1025 people have browsed it

Today’s websites are becoming more and more expressive, and more and more js and css are loaded on the page. When there are too many js and css on the website page, the browser will open the page very slowly, which significantly reduces the user experience. Using mod_concatx, multiple files can be merged into one http response message, which can effectively improve the loading speed of js/css.

The sample effect is as follows:

Using the apache module under Windows to merge multiple js and css to improve web page loading speed

The mod_concatx module is modified based on mod_concat, thanks for their work.

The original mod_concat module has great reference value, but it has little actual use.

This module has the following three problems:

1. Data will be re-sent to the client every time, and the browser cache is not properly used.
2. There are security vulnerabilities that cause the server to The program is downloaded, such as "/??jquery.js,common.php"
3. When merging each file, there is no gap in between, causing the content to stick together, which may cause errors

Instructions for use:

 
Copy after login

Module configuration:

Open the apache configuration file httpd.conf

LoadModule concatx_module modules/mod_concatx.dll
Copy after login

Advanced configuration: (The following is the default configuration, you can not configure it)

 ConcatxDisable Off ConcatxCheckModified On ConcatxSeparator On ConcatxMaxSize 1024 ConcatxMaxCount 10 ConcatxFileType js,css 
Copy after login

Details Description:

ConcatxDisable On/Off //是否使用mod_concatx模块 ConcatxCheckModified On/Off //检查文件是否改动,建议On ConcatxSeparator On/Off //合并文件时是否加换行分隔,建议On ConcatxMaxSize 数字 //合并文件总大小限制最大值,建议不要太大 ConcatxMaxCount 数字 //合并文件总个数限制最大值,建议不要太大 ConcatxFileType js,css //合并文件类型限制,如不限制填","
Copy after login

Final words:
It is recommended to compile this module yourself, safe and secure

Later improvement direction:
todo: Consider adding js, css compression
todo: Consider Support files parsed by zend
bug: There is a default page loading exception in the directory (consider upper-level hook processing)


More uses the apache module under Windows to merge multiple js , css improves web page loading speed related articles, please pay attention to PHP Chinese website!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!