From 7ad27327865167ca0a7ff01fd863af18641a20db Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 20 Aug 2024 17:27:11 +0100 Subject: [PATCH] Add project for caching server --- src/data/projects/caching-server.md | 68 +++++++++++++++++++ src/data/projects/markdown-note-taking-app.md | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/data/projects/caching-server.md diff --git a/src/data/projects/caching-server.md b/src/data/projects/caching-server.md new file mode 100644 index 000000000..611cf58db --- /dev/null +++ b/src/data/projects/caching-server.md @@ -0,0 +1,68 @@ +--- +title: 'Caching Proxy' +description: 'Build a caching proxy server that caches responses from other servers.' +isNew: false +sort: 10 +difficulty: 'intermediate' +nature: 'API' +skills: + - 'Programming Language' + - 'Text Processing' + - 'Markdown libraries' + - 'File Uploads' +seo: + title: 'Caching Proxy Project Idea' + description: 'Build a caching proxy server that caches responses from other servers.' + keywords: + - 'backend project idea' +roadmapIds: + - 'backend' + - 'nodejs' + - 'python' + - 'java' + - 'golang' + - 'spring-boot' +--- + +You are required to build a CLI tool that starts a caching proxy server, it will forward requests to the actual server and cache the responses. If the same request is made again, it will return the cached response instead of forwarding the request to the server. + +## Requirements + +User should be able to start the caching proxy server by running a command like following: + +```shell +caching-proxy --port --origin +``` + +- `--port` is the port on which the caching proxy server will run. +- `--origin` is the URL of the server to which the requests will be forwarded. + +For example, if the user runs the following command: + +```shell +caching-proxy --port 3000 --origin http://dummyjson.com +``` + +The caching proxy server should start on port 3000 and forward requests to `http://dummyjson.com`. + +Taking the above example, if the user makes a request to `http://localhost:3000/products`, the caching proxy server should forward the request to `http://dummyjson.com/products`, return the response along with headers and cache the response. Also, add the headers to the response that indicate whether the response is from the cache or the server. + +```plaintext +# If the response is from the cache +X-Cache: HIT + +# If the response is from the origin server +X-Cache: MISS +``` + +If the same request is made again, the caching proxy server should return the cached response instead of forwarding the request to the server. + +You should also provide a way to clear the cache by running a command like following: + +```shell +caching-proxy --clear-cache +``` + +
+ +After building the above project, you should have a good understanding of how caching works and how you can build a caching proxy server to cache responses from other servers. \ No newline at end of file diff --git a/src/data/projects/markdown-note-taking-app.md b/src/data/projects/markdown-note-taking-app.md index fa0db2b36..978fc6750 100644 --- a/src/data/projects/markdown-note-taking-app.md +++ b/src/data/projects/markdown-note-taking-app.md @@ -12,7 +12,7 @@ skills: - 'File Uploads' seo: title: 'Markdown Note-taking App Project Idea' - description: 'Build an API for an expense tracker application.' + description: 'Build a note-taking app that uses markdown for formatting.' keywords: - 'backend project idea' roadmapIds: