diff --git a/nginx.conf b/nginx.conf index a9b622a884..1b8bb1b244 100644 --- a/nginx.conf +++ b/nginx.conf @@ -21,6 +21,18 @@ server { set $backend "https://apify.github.io/apify-docs"; resolver 1.1.1.1 8.8.8.8 valid=30s ipv6=off; + # Stale Docusaurus chunks: return 410 instead of 404 for missing /assets/{js,css}/* + # so caches/crawlers drop references to hashed bundles removed by a new deploy. + # Scoped to dedicated locations per backend so the nice Docusaurus 404 page is + # preserved for everything else. + location @gone { return 410; } + + location ~ ^/assets/(js/.+\.js|css/.+\.css)$ { + proxy_intercept_errors on; + error_page 404 = @gone; + proxy_pass $backend$request_uri; + } + location = / { if ($serve_markdown) { rewrite ^ /llms.txt last; @@ -63,6 +75,12 @@ server { ### Repository path: "/sdk/js" + location ~ ^/sdk/js/(assets/js/.+\.js|assets/css/.+\.css)$ { + proxy_intercept_errors on; + error_page 404 = @gone; + proxy_pass https://apify.github.io/apify-sdk-js/$1; + } + location = /sdk/js { if ($serve_markdown) { rewrite ^ /sdk-js-llms.txt last; @@ -104,6 +122,12 @@ server { ### Repository path: "/sdk/python" + location ~ ^/sdk/python/(assets/js/.+\.js|assets/css/.+\.css)$ { + proxy_intercept_errors on; + error_page 404 = @gone; + proxy_pass https://apify.github.io/apify-sdk-python/$1; + } + location = /sdk/python { if ($serve_markdown) { rewrite ^ /sdk-python-llms.txt last; @@ -145,6 +169,12 @@ server { ### Repository path: "/api/client/js" + location ~ ^/api/client/js/(assets/js/.+\.js|assets/css/.+\.css)$ { + proxy_intercept_errors on; + error_page 404 = @gone; + proxy_pass https://apify.github.io/apify-client-js/$1; + } + location = /api/client/js { if ($serve_markdown) { rewrite ^ /client-js-llms.txt last; @@ -186,6 +216,12 @@ server { ### Repository path: "/api/client/python" + location ~ ^/api/client/python/(assets/js/.+\.js|assets/css/.+\.css)$ { + proxy_intercept_errors on; + error_page 404 = @gone; + proxy_pass https://apify.github.io/apify-client-python/$1; + } + location = /api/client/python { if ($serve_markdown) { rewrite ^ /client-python-llms.txt last; @@ -227,6 +263,12 @@ server { ### Repository path: "/cli" + location ~ ^/cli/(assets/js/.+\.js|assets/css/.+\.css)$ { + proxy_intercept_errors on; + error_page 404 = @gone; + proxy_pass https://apify.github.io/apify-cli/$1; + } + location = /cli { if ($serve_markdown) { rewrite ^ /cli-llms.txt last;