From a85fe88dea51da63e304ea5f11ceb534081ae620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Mon, 18 May 2026 11:11:02 +0200 Subject: [PATCH 1/3] feat: return 410 status code on missing JS assets --- nginx.conf | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/nginx.conf b/nginx.conf index a9b622a884..0fda54a518 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: when a deploy invalidates hashed JS bundles, signal + # search engine crawlers to drop cached references by returning 410 (Gone) instead of 404. + proxy_intercept_errors on; + error_page 404 = @maybe_gone_js_asset; + + location @maybe_gone_js_asset { + if ($request_uri ~ "/assets/js/[^?]+\.js(\?|$)") { + return 410; + } + return 404; + } + location = / { if ($serve_markdown) { rewrite ^ /llms.txt last; @@ -768,6 +780,18 @@ server { resolver 172.20.0.10; server_name ~^(?[^.]+)\.preview\.docs\.apify\.com$; + # Stale Docusaurus chunks: when a deploy invalidates hashed JS bundles, signal + # search engine crawlers to drop cached references by returning 410 (Gone) instead of 404. + proxy_intercept_errors on; + error_page 404 = @maybe_gone_js_asset; + + location @maybe_gone_js_asset { + if ($request_uri ~ "/assets/js/[^?]+\.js(\?|$)") { + return 410; + } + return 404; + } + # add trailing slashes to the root of GH pages docs rewrite ^/api/client/js$ /api/client/js/ redirect; rewrite ^/api/client/python$ /api/client/python/ redirect; From 596e0cd9efe8a89b22284c9c153715e934af6143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Mon, 18 May 2026 11:27:55 +0200 Subject: [PATCH 2/3] chore: revert changes for the preview server --- nginx.conf | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/nginx.conf b/nginx.conf index 0fda54a518..9e9557e29f 100644 --- a/nginx.conf +++ b/nginx.conf @@ -780,18 +780,6 @@ server { resolver 172.20.0.10; server_name ~^(?[^.]+)\.preview\.docs\.apify\.com$; - # Stale Docusaurus chunks: when a deploy invalidates hashed JS bundles, signal - # search engine crawlers to drop cached references by returning 410 (Gone) instead of 404. - proxy_intercept_errors on; - error_page 404 = @maybe_gone_js_asset; - - location @maybe_gone_js_asset { - if ($request_uri ~ "/assets/js/[^?]+\.js(\?|$)") { - return 410; - } - return 404; - } - # add trailing slashes to the root of GH pages docs rewrite ^/api/client/js$ /api/client/js/ redirect; rewrite ^/api/client/python$ /api/client/python/ redirect; From 8a9548523876c9b9e252ccb77f5bb987b64b6394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Mon, 18 May 2026 11:57:08 +0200 Subject: [PATCH 3/3] chore: test and fix small nginx config discrepancies --- nginx.conf | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/nginx.conf b/nginx.conf index 9e9557e29f..1b8bb1b244 100644 --- a/nginx.conf +++ b/nginx.conf @@ -21,16 +21,16 @@ 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: when a deploy invalidates hashed JS bundles, signal - # search engine crawlers to drop cached references by returning 410 (Gone) instead of 404. - proxy_intercept_errors on; - error_page 404 = @maybe_gone_js_asset; - - location @maybe_gone_js_asset { - if ($request_uri ~ "/assets/js/[^?]+\.js(\?|$)") { - return 410; - } - return 404; + # 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 = / { @@ -75,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; @@ -116,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; @@ -157,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; @@ -198,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; @@ -239,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;