Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(docker): stop the SPA fallback from masking stale hashed assets (#21878)

CCLUCKY0fb5835ae688
diff --git a/docker/nginx/ragflow.conf b/docker/nginx/ragflow.conf
index 1e45825f99..96df1131a4 100644
--- a/docker/nginx/ragflow.conf
+++ b/docker/nginx/ragflow.conf
@@ -24,11 +24,26 @@ server {
location / {
index index.html;
try_files $uri $uri/ /index.html;
+ # The entry document must never come from cache: a stale index.html
+ # references hashed bundles that no longer exist after an image
+ # upgrade.
+ add_header Cache-Control "no-store";
}
- # Cache-Control: max-age Expires
- location ~ ^/static/(css|js|media)/ {
- expires 10y;
+ # Direct navigation to the chunk routes must reach the SPA fallback:
+ # without this block those paths match the hashed-asset location below,
+ # and a missing file answers 404 instead of the app shell. Regex
+ # locations are matched in order, so this must come first.
+ location ~ ^/chunk/(parsed/chunks|chunk/[^/]+|result/[^/]+)$ {
+ try_files $uri $uri/ /index.html;
+ }
+
+ # Hashed bundles are immutable, so they may cache for a year, and a stale
+ # reference after an upgrade must answer 404 instead of the SPA fallback
+ # HTML, which a dynamic import() cannot parse.
+ location ~ ^/(chunk|entry|assets)/ {
+ add_header Cache-Control "public, max-age=31536000, immutable";
access_log off;
+ try_files $uri =404;
}
}
diff --git a/docker/nginx/ragflow.https.conf b/docker/nginx/ragflow.https.conf
index 2ef4cd0059..82b32923aa 100644
--- a/docker/nginx/ragflow.https.conf
+++ b/docker/nginx/ragflow.https.conf
@@ -36,11 +36,26 @@ server {
location / {
index index.html;
try_files $uri $uri/ /index.html;
+ # The entry document must never come from cache: a stale index.html
+ # references hashed bundles that no longer exist after an image
+ # upgrade.
+ add_header Cache-Control "no-store";
}
- # Cache-Control: max-age~@~AExpires
- location ~ ^/static/(css|js|media)/ {
- expires 10y;
+ # Direct navigation to the chunk routes must reach the SPA fallback:
+ # without this block those paths match the hashed-asset location below,
+ # and a missing file answers 404 instead of the app shell. Regex
+ # locations are matched in order, so this must come first.
+ location ~ ^/chunk/(parsed/chunks|chunk/[^/]+|result/[^/]+)$ {
+ try_files $uri $uri/ /index.html;
+ }
+
+ # Hashed bundles are immutable, so they may cache for a year, and a stale
+ # reference after an upgrade must answer 404 instead of the SPA fallback
+ # HTML, which a dynamic import() cannot parse.
+ location ~ ^/(chunk|entry|assets)/ {
+ add_header Cache-Control "public, max-age=31536000, immutable";
access_log off;
+ try_files $uri =404;
}
}