Skip to content

docs: redirect 4.x API doc URLs to 5.x#9396

Open
faraz152 wants to merge 1 commit intosquare:masterfrom
faraz152:docs/9156-fix-4x-doc-links
Open

docs: redirect 4.x API doc URLs to 5.x#9396
faraz152 wants to merge 1 commit intosquare:masterfrom
faraz152:docs/9156-fix-4x-doc-links

Conversation

@faraz152
Copy link
Copy Markdown

Summary

Fixes #9156 — all /okhttp/4.x/ URLs on the project website return 404 because the 4.x API docs were never published to gh-pages. Pages like /features/caching/ that link to /okhttp/4.x/okhttp/okhttp3/-cache/ are broken.

Changes

Both deploy_website.sh and test_docs.sh now generate a docs/4.x/index.html redirect page during the docs build. The redirect:

  • Uses JavaScript window.location.replace() to map /4.x/<path>/5.x/<path> (preserving sub-paths and hash fragments)
  • Falls back to <meta http-equiv="refresh"> for non-JS browsers
  • Shows a user-friendly message with a manual link

This works because 5.x is the direct successor to 4.x with the same okhttp3 package structure.

What's on gh-pages today

1.x/  ✅ (cherry-picked in deploy_website.sh)
2.x/  ✅ (cherry-picked in deploy_website.sh)
3.x/  ✅ (cherry-picked in deploy_website.sh)
4.x/  ❌ 404 — no cherry-pick, no generated docs
5.x/  ✅ (generated by Dokka)

After this PR, 4.x/ will contain a redirect page pointing to 5.x/.

Testing

  1. Verified curl -s -o /dev/null -w "%{http_code}" https://square.github.io/okhttp/4.x/okhttp/okhttp3/-cache/ returns 404
  2. Verified curl -s -o /dev/null -w "%{http_code}" https://square.github.io/okhttp/5.x/okhttp/okhttp3/-cache/ returns 200
  3. Confirmed deploy_website.sh and test_docs.sh both produce the redirect in docs/4.x/

The 4.x API docs were never published to the gh-pages branch,
so all /okhttp/4.x/ URLs return 404. Since 5.x is the direct
successor with the same package structure (okhttp3), redirect
/4.x/ paths to the corresponding /5.x/ path.

Both deploy_website.sh and test_docs.sh now generate a 4.x/
redirect page during the docs build.

Fixes square#9156
@faraz152 faraz152 marked this pull request as ready for review March 30, 2026 12:56
@pvgoran
Copy link
Copy Markdown

pvgoran commented Mar 30, 2026

To me, redirecting 4.x documentation to 5.x seems inappropriate and confusing. OkHttp 5.x is not OkHttp 4.x, so their documentation is not interchangeable.

@faraz152
Copy link
Copy Markdown
Author

Good point — a silent redirect could be confusing since the APIs differ between 4.x and 5.x. Happy to change the approach. Should I instead show a notice page explaining that 4.x API docs aren't published separately, with a link to 5.x as a reference? Or would generating actual 4.x docs from the 4.12.0 tag be preferred?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing documentation for OkHttp 4.x

2 participants