[pull] main from freeCodeCamp:main - #268
Merged
Merged
Conversation
prepare_deploy fetched both index.json and meta.json for every doc version, but the manifest (docs.json) is built solely from meta.json, and clients load index.json directly from documents.devdocs.io at runtime. The local index.json copies were never read. index.json is by far the larger file (e.g. ~1.4 MB for python~3.13 vs ~220 B for meta.json), so downloading it for every version added up to hundreds of MB per deploy and grew steadily as docs/versions were added. The large transfers were also the source of the Net::ReadTimeout retries against the CDN. Fetching only meta.json cuts this phase to a few hundred KB and removes the timeouts. See #2686.
Deep links to docs and the static pages (settings, offline, about, news, help) previously bounced through `/` with a short-lived `initial_path` cookie that the client read back to restore the path. This removes that detour: the server now renders the app shell (erb :index / erb :other) directly at the requested URL, and page.js dispatches location.pathname on start(). This is behaviour that already shipped for docs a user hadn't enabled; enabled docs and the static pages now take the same path. The offline story is unaffected — the service worker already falls back to the cached `/` for non-asset paths when the network fails. Removes the `initial_path` cookie, the redirect_via_js / supports_js_redirection? / modern_browser? helpers, and the client-side getInitialPathFromCookie. The hash-based initial-path handling (used by /search and legacy /#/ bookmarks) is untouched.
Serve app shell directly instead of JS-redirect via cookie
Commit 45867a2 stopped copying index.json into the app's own origin, assuming clients always fetch it from documents.devdocs.io. That holds only when the service worker is disabled. With the service worker enabled (the production default), clients and the service worker precache list load index.json from same-origin /docs to avoid caching the CDN's CORS responses (see App#indexHost / app.js). The missing files caused cache.addAll to reject with "Failed to execute 'addAll' on 'Cache'". The Net::ReadTimeout concern from #2686 that motivated the removal is already handled by the retry/backoff block below this loop. See #2686.
The service worker precache and the runtime index loader used a same-origin /docs path for index.json, on the assumption that the cache couldn't hold the CDN's CORS responses. That assumption dates to the applicationCache era (2013) and is false for service workers, which cache CORS responses fine; documents.devdocs.io already serves index.json with access-control-allow-origin. Point both doc_index_urls (SW precache) and Doc#indexUrl at docs_origin so they load index.json straight from the CDN, and drop the now-dead index_host special-case and index_path config. prepare_deploy no longer needs to copy index.json into the app's public/docs, so stop downloading it — restoring the deploy-size/timeout win from 45867a2 without breaking the service worker. See #2686.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )