nginx空白图片(empty_gif模块)
用过百度统计的兄弟有没有注意到百度使用1x1的空白图片传递统计参数,自己做异步统计的兄弟是否使用静态文件来传递参数。为什么使用空白图片呢,而不是自己存放一张小图呢,nginx里面的空白图片是保存在内存中的,速度绝对比硬盘上读取的快. 看下如何使用empty_gif生成响应1x1的空白图片吧.
或许哪天ttlsa自己要做统计,咱们也可以使用empty_gif来传递参数,说归说,肯定性还是比较小,能用第三方的统计就用第三方统计。好了,进入正题吧。
nginx默认内置ngx_http_empty_gif_module模块, 如何安装nginx我不在多讲.直接看下empty_gif的用法
nginx配置
nginx模块ngx_http_empty_gif_module会响应1x1的GIF图片.
empty_gif;
}
|
1
2
3
|
location = /_.gif {
empty_gif;
}
|
如下是我的nginx配置
listen 80;
server_name test.ttlsa.com;
access_log /data/logs/nginx/test.ttlsa.com.access.log main;
index index.html index.<a href="http://www.ttlsa.com/php/" title="php"target="_blank">php</a> index.html;
root /data/site/test.ttlsa.com;
location ~* /3145/
{
empty_gif;
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
server {
listen 80;
server_name test.ttlsa.com;
access_log /data/logs/nginx/test.ttlsa.com.access.log main;
index index.html index.php index.html;
root /data/site/test.ttlsa.com;
location ~* /3145/
{
empty_gif;
}
}
|
测试empty_gif
访问test.ttlsa.com/3145/结果如下:
empty_gif nginx空白图片
empty_gif指令
语法: empty_gif;
默认: —
配置段: location
开启响应1x1空白图片
最后
empty_gif用得最多的地方还是统计,当然你觉得可以用的地方也是可以用,只要是你用得着,毕竟内存速度比硬盘要快非常多.
nginx空白图片(empty_gif模块)的更多相关文章
- Nginx使用图片处理模块
Nginx可以编写很多额外的模块,这里我们需要按照能够通过URL响应返回缩放且含图片水印功能的模块. 1.安装一些使用过程中会用到的工具 yum install libgd2-devel yum in ...
- nginx通过配置empty_gif解决请求favicon 404的问题
背景介绍 因为一些浏览器在访问网站时会默认去请求网站的favicon,但是我的网站(Tengine)上并没有这些icon图片,因此在访问日志里会出现大量的404错误,会触发一些没必要日志告警.我们可以 ...
- Nginx/Apache图片缩略图技术
1,目的 2,使用方式 3,Nginx + Linux 缩略图实现 3.1,原理 3.2,nginx配置实现 3.3,例子 4,Apache + Windows缩略图实现 4.1,环境 4.2,原理 ...
- yum安装下的nginx,如何添加模块,和添加第三方模块
需求:生产有个接口是通过socket通信.nginx1.9开始支持tcp层的转发,通过stream实现的,而socket也是基于tcp通信. 实现方法:Centos7.2下yum直接安装的nginx, ...
- Nginx加载ngx_pagespeed模块,加快网站打开的速度
[页面加速]配置Nginx加载ngx_pagespeed模块,加快网站打开的速度 ngx_pagespeed 是一个 Nginx 的扩展模块,可以加速你的网站,减少页面加载时间,它会自动将一些提升 ...
- Nginx 安装--图片服务器搭建
1. nginx 需要依赖以下模块: gzip模块需要 zlib 库 rewrite模块需要 pcre 库 ssl 功能需要openssl库 1.1.安装pcre 1. 获取pcre ...
- 转:Nginx国人开发缩略图模块(ngx_image_thumb)
ngx_image_thumb是nginx中用来生成缩略图的模块,生存缩略图的方法很多,之前也写过一篇 <nginx生成缩略图配置>,在github上发现国人开发的一款模块,作者的文档写的 ...
- Nginx核心流程及模块介绍
Nginx核心流程及模块介绍 1. Nginx简介以及特点 Nginx简介: Nginx (engine x) 是一个高性能的web服务器和反向代理服务器,也是一个IMAP/POP3/SMTP服务器 ...
- Nginx,Nginx 搭建图片服务器
Nginx Nginx 概述 反向代理 工作流程 优点 1:保护了真实的web服务器,保证了web服务器的资源安全 2:节约了有限的IP地址资源 3:减少WEB服务器压力,提高响应速度 4:其他优点 ...
随机推荐
- typedef define typedef可以使程序参数化,提高程序的可移植性。
小结: 1. typedef并没有创建一个新类型,它只是为某个已存在的类型增加了一个新的名称而已: 2. typedef声明也没有证据新的语义:通过这种方式声明的变量与通过普通方式声明的变量具有完全相 ...
- [skill][makefile] makefile 常用内容记录
其实,makefile有点复杂. 文档看了又看,还是要经常翻,做个记录备忘 :) 1. 隐含命令 implicit rules 与 implicit rule 相对应的有 pattern rules ...
- LeetCode 463 Island Perimeter 解题报告
题目要求 You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 rep ...
- LeetCode 876 Middle of the Linked List 解题报告
题目要求 Given a non-empty, singly linked list with head node head, return a middle node of linked list. ...
- Appium-两个小报错
(1) 执行脚本appium报错:> info: [debug] Emulator not running appium设置中取消勾选launch avd解决 (2)执行脚本python ...
- linux 源码安装 mono
$ yum install bison gettext glib2 freetype fontconfig libpng libpng-devel libX11 libX11-devel glib2- ...
- 获取文件后缀名(zip,rar等)
var filename = file.name; var index1 = filename.lastIndexOf("."); var index2 = filename.le ...
- jquery实现简单的弹出框
弹出框本身是一个div,默认是隐藏不展示的,在需要弹框的时候使其显示,并浮在当前页面之上 弹框样式: .tanchuang { width: 100%; height: 100%; display: ...
- FlashFXP+FileZillaServer
从远程站点里拷贝文件到本地时,如果文件太大,通常会非常耗时,再加上若需要拨VPN,网络上的任何波动都会造成传输文件失败从头来过. 运用FlashFXP和FileZillaServer这两个工具,它拥有 ...
- mv 命令
[root@localhost soft]# .txt [root@localhost soft]# [root@localhost soft]# ls .txt [root@localhost so ...