want to know how most url shortening scripts work? The answer is surprisingly simple! see this: http://digg.com/programming/How_URL_shortening_scripts_work very interesting article!
A lot simpler than I thought. You'd need a fast server to handle all the requests and you'll also need to check whether a URL already exists in the database. A website like TinyURL must receive so many links that they must have to clear old links after some time. Does anyone know how long the links are active for?
True. I guess it would be very easy to set up a cron job to do that. What would be a useful feature is if you could set how long you'll need the link to be active for. e.g. if I'm PM'ing you a link, it would only need to be active for a short time whereas if a magazine is printing a shortened URL, it would need to be active for much longer.
Uh, I don't think tinyurl or any other big url shortener should ever delete links.. That would result in a very bad user experience because those links aren't deleted from all over the web and would result in 404 not founds.
As the no of URLs you store reach millions, your database alone would be many GB in size. In that case your server will be slow. Of course you have to check the duplicates and redundant data. It is unlikely that they would delete the link, but can disable redirecting to destination URL.
Maybe, but I was referring to well out dated links, the kind people make before they start to use the services for real, ie: if a link generated 2 or 3 hits on the day it was created, 2 years ago, that kind of link could safely be removed. Or even a link generated 5 years ago, that hasn't received any hits in the last 2. 404 not founds, not to many of those around, most use the 404 htaccess tricks these days or something similar.
just just put the long url into mysql and some other filed with ID for example and then you give out just the ID from mysql and the link has just the id in the url instead of the long url... just an example.. :>