2 Star 0 Fork 0

陈登禄 / nginx-lua-static-merger

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

nginx-lua-static-merger



About

详细教程请看:http://homeway.me/2015/06/22/nginx-lua-static-merger/

nginx-lua-static-merger是一个基于openresty的模块,主要用于合并静态文件,减少http请求,加快静态文件访问速度的模块。

使用nginx-lua-static-merger 需要在编译nginx时候添加openresty的模块,或者直接安装openresty作为服务器。

nginx-lua-static-merger可以让你的js、css请求不要那么多,一个就够了。

nginx-lua-static-merger

Usage

install openresty

http://openresty.org/cn/

wget http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz
tar xzvf ngx_openresty-1.7.10.1.tar.gz
cd ngx_openresty-1.7.10.1/
./configure
make
make install

install nginx-lua-static-merger

$git clone https://github.com/grasses/nginx-lua-static-merger

$cd nginx-lua-static-merger

$chmod +x install

$./install

Remember install openresty before run install script.

file path

|--/usr/local/openresty/nginx
|						`--lua
|							`--nginx-lua-static-merger.lua
|						`--conf 
|							`--nginx.lua
|--/www/openresty/static
|				`--js
|				`--css
|				`--cache

注意

1、nginx.conf中的lua_package_path "/usr/local/openresty/lualib/?.lua;;";lua_package_cpath "/usr/local/openresty/lualib/?.so;;";,如果你是编译nginx而不是直接安装openresty,目录记得放对。

2、确保/www/openresty/static有Lua写的权限。

use

前端调用方法如下:

<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css;/qiniu/css/main.css;/css/navbar.css">
<script src="/js/jquery.min.js;/js/main.js;/qiniu/bootstrap/js/bootstrap.min.js;/qiniu/js/plupload/plupload.full.min.js;/qiniu/js/plupload/i18n/zh_CN.js"></script>


How it work

Nginx在location通过 content_by_lua_file 把接下来的处理丢个Lua做逻辑。

Lua通过uri进行md5编码,判断cache是否存在,如果cache不存在,循环分割、遍历uri,访问响应的路径,查找静态文件,存在则记录,最后写cache入文件,方便下次访问。

how nginx-lua-static-merger work

Version

15.06.22

  • Beta Version

15.06.26

  • Fix a bug (single static file error)

  • Add install script



License

GPL

空文件

简介

Static file merger base on openresty 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Lua
1
https://gitee.com/amango/nginx-lua-static-merger.git
git@gitee.com:amango/nginx-lua-static-merger.git
amango
nginx-lua-static-merger
nginx-lua-static-merger
master

搜索帮助