请求的路径是 请求 -> nginx(第一层) -> 前端 docker -> docker 内 nginx(第二层,指向 html)
服务有两层 nginx ,分别配置如下
第一层
location / { proxy_pass http://xxx/; proxy_max_temp_file_size 0k; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; add_header X-Frame-Options "SAMEORIGIN"; proxy_buffering on; proxy_cache_valid any 60m; }
第二层
server { listen 8080; server_name 172.18.162.xx; add_header X-Frame-Options sameorigin always; root /data/app/dist; try_files $uri $uri/ /index.html; index index.html index.htm; add_header Cache-Control no-cache; add_header Cache-Control private; # gzip location ~ .*\.(js|css)?$ { gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 6; gzip_types text/plain application/x-Javascript text/css text/Javascript application/Javascript application/json image/jpeg image/png image gzip_disable "MSIE [1-6]\."; expires 30d; add_header Pragma public; add_header Cache-Control "public"; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }
响应头
cache-control: max-age=2592000 content-encoding: gzip content-type: text/css date: Tue, 26 Oct 2021 12:50:14 GMT etag: W/"61729535-86694" expires: Thu, 25 Nov 2021 12:50:14 GMT last-modified: Fri, 22 Oct 2021 10:40:53 GMT server: nginx/1.20.1 strict-transport-security: max-age=63072000; includeSubdomains; preload x-frame-options: sameorigin x-frame-options: SAMEORIGIN
请求头
:authority: 172.18.162.190 :method: GET :path: /css/common.06e66be2.css :scheme: https accept: text/css,*/*;q=0.1 accept-encoding: gzip, deflate, br accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6 cookie: dnt: 1 referer: https://172.18.162.190/training/client/mobile/examing/1 sec-ch-ua: "Microsoft Edge";v="93", " Not;A Brand";v="99", "Chromium";v="93" sec-ch-ua-mobile: ?1 sec-ch-ua-platform: "Android" sec-fetch-dest: style sec-fetch-mode: no-cors sec-fetch-site: same-origin user-agent: Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Mobile Safari/537.36 Edg/93.0.961.47
主要问题是浏览器拿 js/css 文件时,只会 200 ,快速刷新时使用内存缓存,过几分钟请求依旧是 200 ,不会走磁盘缓存或者 304 。 试了很多配置都不行,想问一下。
![]() | 1 wellsc 2021-10-26 21:20:56 +08:00 只用一个代理不行嘛 |