Home php教程 PHP开发 Using the apache module under Windows to merge multiple js and css to improve web page loading speed

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

Jan 04, 2017 am 10:39 AM

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:

<link href="/style/??css1.css,css2.css,css3.css" type="text/css" rel="stylesheet"/>
<script src="/js/??js1.js,js2.js,js3.js,js4.js" type="text/javascript"></script>
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)

<IfModule concatx_module>
ConcatxDisable Off
ConcatxCheckModified On
ConcatxSeparator On
ConcatxMaxSize 1024
ConcatxMaxCount 10
ConcatxFileType js,css
</IfModule>
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!


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)