Skip to content

Commit bbab597

Browse files
authored
Update src/archives/README.md (#58852)
1 parent d3a61e5 commit bbab597

File tree

1 file changed

+83
-2
lines changed

1 file changed

+83
-2
lines changed

src/archives/README.md

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,86 @@
11
# Archives
22

3-
Product oriented code to handle archived versions of the Docs, such as archived Enterprise Server versions.
3+
This directory contains the infrastructure for serving archived versions of GitHub Docs, primarily for deprecated GitHub Enterprise Server (GHES) releases.
44

5-
The directory `versions/` handles non-archived versions of the docs. `ghes-releases/` handles version releases and deprecations processes.
5+
## Purpose & Scope
6+
7+
To keep the main documentation site fast and the build lightweight, we do not build deprecated GHES versions from source. Instead, we serve them as static snapshots. This directory provides the middleware that:
8+
9+
1. **Detects** requests for archived versions.
10+
2. **Proxies** the HTML and assets from their static hosting location.
11+
3. **Rewrites** content on-the-fly to ensure links and assets work correctly within the current site structure.
12+
13+
## Architecture
14+
15+
The system acts as a reverse proxy for specific URL paths.
16+
17+
### Directory Structure
18+
19+
- **`middleware/`**
20+
- `archived-enterprise-versions.ts`: The primary handler. It:
21+
- Checks if a URL belongs to a deprecated version.
22+
- Fetches the content from the external host.
23+
- Rewrites HTML (e.g., fixing image paths, injecting new headers).
24+
- Handles redirects defined in the archived version's `redirects.json`.
25+
- `archived-enterprise-versions-assets.ts`: Proxies static assets (CSS, JS, fonts) from the archive host.
26+
- `archived-asset-redirects.ts`: Maps legacy asset paths to modern equivalents where possible.
27+
- **`lib/`**
28+
- `is-archived-version.ts`: Utilities to parse URLs and check against the list of deprecated versions defined in `src/versions`.
29+
- **`scripts/`**
30+
- `warmup-remotejson.ts`: Utility to prime caches for remote JSON files.
31+
32+
### Request Flow
33+
34+
```mermaid
35+
graph TD
36+
A[Incoming Request] --> B{Is Archived Version?}
37+
B -- No --> C[Next Middleware]
38+
B -- Yes --> D{Is Asset?}
39+
D -- Yes --> E[archived-enterprise-versions-assets]
40+
D -- No --> F[archived-enterprise-versions]
41+
E --> G[Fetch from docs-ghes-X.X repo]
42+
F --> H[Fetch HTML from docs-ghes-X.X repo]
43+
H --> I[Rewrite Body & Headers]
44+
I --> J[Serve Response]
45+
G --> J
46+
```
47+
48+
## Data & External Dependencies
49+
50+
### External Hosting
51+
Archived versions are hosted as static sites on GitHub Pages, typically in repositories named `github/docs-ghes-<version>`.
52+
- **Source**: `https://github.github.com/docs-ghes-<version>`
53+
- **Content**: These repos contain the fully built static HTML and assets for that version at the time of its deprecation.
54+
55+
### Internal Dependencies
56+
- **`src/versions`**: The `deprecated` array in `src/versions/lib/enterprise-server-releases.ts` is the source of truth for which versions are handled by this middleware.
57+
- **`src/frame`**: Uses shared patterns and fetch utilities.
58+
59+
## Setup & Usage
60+
61+
This functionality is enabled by default in the application.
62+
63+
### Local Development
64+
To test archived versions locally:
65+
1. Ensure you have internet access (the middleware fetches from public URLs).
66+
2. Navigate to a deprecated version URL, e.g., `http://localhost:4000/enterprise-server@3.0`.
67+
68+
### Adding a New Archive
69+
When a GHES version is deprecated:
70+
1. A static snapshot is created and pushed to a `docs-ghes-<version>` repository.
71+
2. The version is moved to the `deprecated` list in `src/versions/lib/enterprise-server-releases.ts`.
72+
3. This middleware automatically starts handling requests for that version.
73+
74+
## Ownership & Cross-links
75+
76+
- **Owner**: Docs Engineering
77+
- **Related Code**:
78+
- `src/versions`: Version configuration.
79+
- `src/ghes-releases`: Release lifecycle management.
80+
81+
## Current State & Next Steps
82+
83+
- **Health**: The system is stable (KTLO) but relies on the availability of the external GitHub Pages sites. A new version is deprecated and added to this system approximately once per quarter.
84+
- **Known Issues**:
85+
- "Flash of content" or layout shifts can occur if CSS proxies are slow.
86+
- Search is generally disabled or limited for archived versions.

0 commit comments

Comments
 (0)