nginx配置静态文件过期时间
2017-06-14 17:51
302 查看
nginx配置静态文件过期时间
如何配置静态文件的缓存(过期时间)
[root@LHQ ~]# cd /usr/local/nginx/conf/vhosts/
编辑配置文件:
[root@LHQ vhosts]# vim test.conf
server
{
listen 80;
server_name www.test.com www.aaa.com www.bbb.com;
if ($host != 'www.test.com')
{
rewrite ^/(.*)$ http://www.test.com/$1 permanent;
}
index index.html index.htm index.php;
root /data/www;
access_log /tmp/access.log qiangzi;
location ~ .*admin\.php$ {
auth_basic "aminglinux auth";
auth_basic_usre_file /usr/local/nginx/conf/.htpasswd;
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$
{
access_log off;
expires 15d;
}
localtion ~\(js|css)
{
access_log off;
expires 2h;
}
location ~(static|cache)
{
access_log off;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
}
保存退出
[root@LHQ vhosts]# /usr/local/nginx/sbin/nginx -t
[root@LHQ vhosts]# /usr/local/nginx/sbin/nginx -s reload (重新加载)
在浏览器里按“F12”也可以用“curl”
[root@LHQ vhosts]# curl -x127.0.0.1:80 'http://www.test.com/static/js/ajax.js?ndr' -I
和Apache有一定的差别
如何配置静态文件的缓存(过期时间)
[root@LHQ ~]# cd /usr/local/nginx/conf/vhosts/
编辑配置文件:
[root@LHQ vhosts]# vim test.conf
server
{
listen 80;
server_name www.test.com www.aaa.com www.bbb.com;
if ($host != 'www.test.com')
{
rewrite ^/(.*)$ http://www.test.com/$1 permanent;
}
index index.html index.htm index.php;
root /data/www;
access_log /tmp/access.log qiangzi;
location ~ .*admin\.php$ {
auth_basic "aminglinux auth";
auth_basic_usre_file /usr/local/nginx/conf/.htpasswd;
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$
{
access_log off;
expires 15d;
}
localtion ~\(js|css)
{
access_log off;
expires 2h;
}
location ~(static|cache)
{
access_log off;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/www.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
}
保存退出
[root@LHQ vhosts]# /usr/local/nginx/sbin/nginx -t
[root@LHQ vhosts]# /usr/local/nginx/sbin/nginx -s reload (重新加载)
在浏览器里按“F12”也可以用“curl”
[root@LHQ vhosts]# curl -x127.0.0.1:80 'http://www.test.com/static/js/ajax.js?ndr' -I
和Apache有一定的差别
相关文章推荐
- nginx配置静态文件过期时间
- Nginx如何配置静态文件过期时间
- 2.1-nginx配置静态文件过期时间
- nginx配置静态文件过期时间
- nginx配置静态文件过期时间
- Nginx 配置静态文件过期时间&防盗链
- nginx配置静态文件过期时间
- LNMP搭建10:Nginx配置静态文件过期时间
- CentOS7 Nginx配置--静态文件过期时间、防盗链、访问控制
- LNMP - nginx配置静态文件过期时间
- Nginx配置——配置静态文件过期时间
- LNMP - Nginx配置静态文件缓存时间
- 12.10 Nginx访问日志 12.11 Nginx日志切割 12.12 静态文件不记录日志和过期时间
- Nginx访问日志,Nginx日志切割,静态文件不记录日志和过期时间
- Nginx访问日志,Nginx日志切割,静态文件不记录日志和过期时间
- Nginx访问日志、日志切割、静态文件不记录日志和过期时间
- nginx配置静态文件expires时间 cache-control
- 十二周三次课 2018.01.04 Nginx访问日志、Nginx日志切割、静态文件不记录日志和过期时间
- Nginx设置Js、Css等静态文件的缓存过期时间
- 【LNMP】Nginx访问日志、Nginx日志切割、静态文件不记录日志和过期时间