设置文件永远不从缓存读取
<!DOCTYPE html>
<html lang="en" class="theme-light">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="./logo.ico">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--缓存设置相关start-->
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<!--缓存设置相关end -->
<title>xxxxx</title>
</head>
<body >
<div id="webRis"></div>
</body>
</html>
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 17001;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#缓存设置相关start
location / {
root html;
index index.html;
expires -1s;
}
#设置所有yml、HTML类型文件不缓存
location ~ .*\.(yml|html)$ {
add_header Cache-Control no-store;
}
#缓存设置相关end
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
#gzip模块设置
gzip off; #开启gzip压缩输出
# gzip_static on; #nginx对于静态文件的处理模块,该模块可以读取预先压缩的gz文件,这样可以减少每次请求进行gzip压缩的CPU资源消耗。该模块启用后,nginx首先检查是否存在请求静态文件的gz结尾的文件,如果有则直接返回该gz文件内容。为了要兼容不支持gzip的浏览器,启用gzip_static模块就必须同时保留原始静态文件和gz文件。这样的话,在有大量静态文件的情况下,将会大大增加磁盘空间。我们可以利用nginx的反向代理功能实现只保留gz文件。
# gzip_disable "MSIE [1-6]\.(?!.*SV1)"; #禁用IE6的gzip压缩,IE6的某些版本对gzip的压缩支持很不好,会造成页面的假死
# gzip_min_length 10k; #设置允许压缩的页面最小字节,页面字节数从header头的Content-Length中获取,默认值是0,不管页面多大都进行压缩。建议设置成大于1K。如果小于1K可能越压越大
# gzip_buffers 4 16k; #压缩缓冲区,设置系统获取几个单位的缓存用于存储gzip的压缩结果数据流。4 16k代表以16k为单位,安装原始数据大小以16k为单位的4倍申请内存 。如果没有设置,默认值是申请跟原始数据相同大小的内存空间去存储gzip压缩结果
# gzip_comp_level 4; #压缩s级别 1-9,默认值:1(建议选择为4),级别越高压缩率越大,当然压缩时间也就越长(传输快但比较消耗cpu)
# gzip_types text/xml text/css application/javascript; #压缩类型,匹配MIME类型进行压缩,设置哪压缩种文本文件可参考 conf/mime.types,(无论是否指定)text/html默认已经压缩,默认不对js/css文件进行压缩,不能用通配符 text/*
# gzip_proxied off; #作为反向代理的时候启用,开启或者关闭后端服务器返回的结果,匹配的前提是后端服务器必须要返回包含"Via"的 header头。
# #默认值:off [off|expired|no-cache|no-store|private|no_last_modified|no_etag|auth|any]
# #off - 关闭所有的代理结果数据的压缩
# #expired - 启用压缩,如果header头中包含 "Expires" 头信息
# #no-cache - 启用压缩,如果header头中包含 "Cache-Control:no-cache" 头信息
# #no-store - 启用压缩,如果header头中包含 "Cache-Control:no-store" 头信息
# #private - 启用压缩,如果header头中包含 "Cache-Control:private" 头信息
# #no_last_modified - 启用压缩,如果header头中不包含 "Last-Modified" 头信息
# #no_etag - 启用压缩 ,如果header头中不包含 "ETag" 头信息
# #auth - 启用压缩 , 如果header头中包含 "Authorization" 头信息
# #any - 无条件启用压缩
# gzip_vary on;
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
1.在nginx根目录放置文件stop.bat,并执行此文件以杀掉所有nginx进程,内容如下:
cd /d %~dp0
taskkill /f /im nginx.exe
del logs\*.log
nginx -s stop
ping 127.0.0.1 -n 10 >nul
2.执行nginx.exe重启nginx