-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat: implement url shortener service #1
base: main
Are you sure you want to change the base?
Conversation
…ion helpers; create app constants
… required data from request in history kv
Deploying url-shortener with Cloudflare Pages
|
@@ -0,0 +1,57 @@ | |||
<script lang="ts"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be invalidation on reload, I think its not nice to cache stats page (you make few clicks, go to stats page and its empty)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do invalidateAll in onMount on each dynamic data page - /shortUrl/stats and /list but nothing changed. I also check without cache in the browser and from incognito tabs. I think the problem is in Cloudflare KV, the latency from write to read is too big, and i read few post and KV docs where people said that it can be happed, maybe because of hot and cold reads.
So i think maybe Cloudflare KV is not perfect match for this kind of task or maybe it need to be used as a cache, not storage
https://developers.cloudflare.com/kv/reference/how-kv-works/
https://community.cloudflare.com/t/delay-in-workers-kv/149463
try to put as url:
|
try { | ||
parsedUrl = new URL(url); | ||
} catch (_) { | ||
throw new CreateUrlError('url', 'Invalid URL'); | ||
} | ||
|
||
if (!allowedProtocols.includes(parsedUrl.protocol)) { | ||
throw new CreateUrlError('url', 'Only HTTP and HTTPS URLs are allowed'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read about URL.canParse method, but i need also check protocol of the actual url and canParse does not allowe this, so the solution was bettwen native api and regexp i choose first approach
Tasks: