Skip to content

abhishekarya1/cachemeifyoucan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📓 cachemeifyoucan!

Simple link shortener with powerful and efficient webpage archive.

     

About

Shortened links that redirects to the original. If the original is down, a cached version of the webpage is displayed.

Built With

Libraries used

Concepts and working

  • In-memory data store
  • Webpage scraping
  • HTML templating
  • Character encodings (bytes and strings)

Endpoints

/ (GET, POST) : A link is input on the page by the user and all <style> and <script> are stripped from it, only plain HTML is kept, hyperlinks are disabled too. The plain HTML code is then encoded using base64encoding. The b64_code is searched in data store and if found, a previously generated shortid is returned to the user. If this is the first time that link is being shortened, then a shortie is generated (using Hashids library) based on the current timestamp and added to data store alongwith link and b64_code.

The link, shortid, and b64_code is stored to redis following the given schema: redis_schema

/shortid (GET) : shortid from the link is lookedup in data store and if not found an "Invalid shortlink!" message is shown to the user. If a valid shortid is found, then the corresponding b64_code and link values are fetched. If the fetched link is up (returns a success response code 200) then user is redirected to it, else b64_code fetched from store is decoded to display cached version of the webpage.

References

Acknowledgements

Further

  • A similar tool
  • Save page as an image or pdf format (maybe)
  • Add option to view cached page before redirect

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published