Nginx 配置浏览器缓存
- 强缓存
- <- cache-control: max-age=600 ---- no-store 不缓存 no-cache 不使用强缓存
- <- expires: Mon, 14 Sep 2020 09:02:20 GMT
- 协商缓存
- <- last-modified: Fri, 07 Aug 2020 02:35:59 GMT
- -> if-modified-since: Fri, 07 Aug 2020 02:35:59 GMT
- <- etag: W/“5f2cbe0f-2382"
- -> if-none-match: W/"5f2cbe0f-2382"
Nginx 配置
http {
gzip on;
gzip_min_length 1k;
gzip_comp_level 5;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
etag on;
}
server {
location ~* \.(html)$ {
access_log off
add_header Cache-Control max-age=no-cache
}
location ~* \.(css|js|png|jpg|jpeg|gif|gz|svg|mp4|ogg|ogv|webm|htc|xml|woff)$ {
access_log off
add_header Cache-Control max-age=360000
}
}
HTTPS 配置
ssl_certificate "/etc/pki/nginx/server.crt";
ssl_certificate_key "/etc/pki/nginx/private/server.key";
- 安全组规则里打开 443 端口
- HTTP/2 演示
return 301 https://www.nllcoder.com$request_uri;
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name www.nllcoder.com;
root /usr/share/nginx/html;
ssl_certificate "/etc/pki/nginx/www.nllcoder.com_bundle.crt";
ssl_certificate_key "/etc/pki/nginx/private/www.nllcoder.com.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers PROFILE=SYSTEM;
ssl_prefer_server_ciphers on;
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}