📕
blog
  • Hi there
  • javascript
    • 柯里化 - Curry
    • 观察者和订阅-发布模式
    • generator
    • 发布订阅-依赖于window
    • pwa manual trigger install
  • browser
    • beautify scrollbar
  • http
    • nginx 缓存配置
  • extra
    • vue-cli 不使用 .env[.xxx] 文件,添加额外运行时参数
    • docker-compose nginx with ssl config
  • React
    • How React works
Powered by GitBook
On this page

Was this helpful?

  1. http

nginx 缓存配置

将index.html不缓存,其他资源文件缓存最大5天,也可以更长时间

#user  nobody;

worker_processes 2;

events {
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout 65;

    gzip on;
    gzip_static on;
    gzip_min_length 1024;
    gzip_buffers 4 16k;
    gzip_comp_level 2;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";

    server {
        listen 80;
        charset utf-8;

        location / {
            root /usr/src/app;
            index index.html index.htm;
            try_files $uri $uri/ @rewrites;
            
            if ($request_filename ~ .*\.(htm|html)$)
            {
                add_header Cache-Control no-cache,no-store,must-revalidate;
            }
            add_header Cache-Control public,max-age=432000;
        }

        location ~ ^/api {
            rewrite ^/api(.*)$ $1 break;
            proxy_pass http://192.168.1.99;
        }

        location @rewrites {
            rewrite ^(.*)$ /index.html last;
        }

        error_page 500 502 503 504 /50x.html;

        location = /50x.html {
            root html;
        }
    }
}
Previousbeautify scrollbarNextvue-cli 不使用 .env[.xxx] 文件,添加额外运行时参数

Last updated 4 years ago

Was this helpful?