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

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>

Module configuration:

Open the apache configuration file httpd.conf

LoadModule concatx_module modules/mod_concatx.dll

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>

Details Description:

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

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
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)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.