feat: 部署优化
This commit is contained in:
@@ -5,6 +5,10 @@ server {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# 跨域隔离头(SharedArrayBuffer / WASM 线程模式所需)
|
||||
add_header Cross-Origin-Opener-Policy "same-origin";
|
||||
add_header Cross-Origin-Embedder-Policy "require-corp";
|
||||
|
||||
# 前端静态资源
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
@@ -33,7 +37,35 @@ server {
|
||||
proxy_send_timeout 86400s;
|
||||
}
|
||||
|
||||
# 静态资源缓存
|
||||
# ONNX Runtime WASM 模块(.mjs 必须是 JS MIME 类型)
|
||||
location ~* \.mjs$ {
|
||||
types { }
|
||||
default_type application/javascript;
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
add_header Cross-Origin-Opener-Policy "same-origin";
|
||||
add_header Cross-Origin-Embedder-Policy "require-corp";
|
||||
}
|
||||
|
||||
# WebAssembly 二进制文件
|
||||
location ~* \.wasm$ {
|
||||
types { }
|
||||
default_type application/wasm;
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
add_header Cross-Origin-Opener-Policy "same-origin";
|
||||
add_header Cross-Origin-Embedder-Policy "require-corp";
|
||||
}
|
||||
|
||||
# ONNX 模型文件
|
||||
location ~* \.onnx$ {
|
||||
types { }
|
||||
default_type application/octet-stream;
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 其他静态资源缓存
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
@@ -41,6 +73,6 @@ server {
|
||||
|
||||
# Gzip 压缩
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/wasm;
|
||||
gzip_min_length 256;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user