Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support default human readable URLs #44

Merged
merged 2 commits into from
Sep 12, 2024
Merged

Support default human readable URLs #44

merged 2 commits into from
Sep 12, 2024

Conversation

zephraph
Copy link
Owner

@zephraph zephraph commented Sep 12, 2024

My site is just a collection of markdown files with ULID filenames. Multiple top level URLs can point to a ULID file, but I only want one canonical URL. The other urls should just redirect to that canonical.

This PR introduces a mapping where URLs are normalized to the ULID via a KV look up and then converted to the canonical URL via another KV lookup. I'm sensitive of the fact that there are now two requests on the render path so I introduced some caching mechanisms for the lookups themselves. Longer term I'll tweak the caching from the CDN side just to invoke the worker less often so it shouldn't be as big of a concern.

Copy link

cloudflare-workers-and-pages bot commented Sep 12, 2024

Deploying just-be-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: ccd91e4
Status: ✅  Deploy successful!
Preview URL: https://d6b63fb0.just-be-dev.pages.dev
Branch Preview URL: https://canonical-urls.just-be-dev.pages.dev

View logs

@zephraph zephraph marked this pull request as ready for review September 12, 2024 15:38
@zephraph zephraph merged commit 8e28f61 into main Sep 12, 2024
2 checks passed
@zephraph zephraph deleted the canonical-urls branch September 12, 2024 15:57
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.

1 participant