This pull request adds support for caching HTTP requests, enabling efficient redirection of users to the original URL after caching and fewer calls to the database. It optimizes performance by storing frequently accessed short URLs in memcached for quick access.
Here's a simple micro-benchmark using UNIX time command:
Without caching
[hamza@archlinux shawty]$ time curl -i http://localhost:1234/s/996e1f71
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: https://github.com
Date: Mon, 16 Sep 2024 04:04:19 GMT
Content-Length: 41
<a href="https://github.com">Found</a>.
real 0m0.968s # 0.968 seconds
user 0m0.004s
sys 0m0.004s
With caching enabled
[hamza@archlinux shawty]$ time curl -i http://localhost:1234/s/996e1f71
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: https://github.com
Date: Mon, 16 Sep 2024 04:04:24 GMT
Content-Length: 41
<a href="https://github.com">Found</a>.
real 0m0.408s # 0.408 seconds
user 0m0.004s
sys 0m0.004s
Caching using Memcached
This pull request adds support for caching HTTP requests, enabling efficient redirection of users to the original URL after caching and fewer calls to the database. It optimizes performance by storing frequently accessed short URLs in
memcached
for quick access.Here's a simple micro-benchmark using UNIX
time
command:Without caching
With caching enabled