{"id":17429883,"url":"https://github.com/ajaysinghj8/osham","last_synced_at":"2025-04-09T07:07:31.241Z","repository":{"id":34651255,"uuid":"181733377","full_name":"ajaysinghj8/osham","owner":"ajaysinghj8","description":"A Configurable Proxy + Cache Server.","archived":false,"fork":false,"pushed_at":"2025-02-12T07:55:20.000Z","size":821,"stargazers_count":55,"open_issues_count":27,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-02T06:07:08.505Z","etag":null,"topics":["cache","cache-server","cache-service","configurable","nodejs","proxy","proxy-server","proxyserver","redis","redis-cache","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajaysinghj8.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-16T17:10:12.000Z","updated_at":"2023-03-18T17:38:22.000Z","dependencies_parsed_at":"2024-10-21T12:06:55.889Z","dependency_job_id":null,"html_url":"https://github.com/ajaysinghj8/osham","commit_stats":{"total_commits":117,"total_committers":8,"mean_commits":14.625,"dds":"0.33333333333333337","last_synced_commit":"74899a8ce12b60107f7a6a9aebfc8cd584982d11"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajaysinghj8%2Fosham","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajaysinghj8%2Fosham/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajaysinghj8%2Fosham/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajaysinghj8%2Fosham/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajaysinghj8","download_url":"https://codeload.github.com/ajaysinghj8/osham/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994121,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","cache-server","cache-service","configurable","nodejs","proxy","proxy-server","proxyserver","redis","redis-cache","typescript"],"created_at":"2024-10-17T07:10:25.675Z","updated_at":"2025-04-09T07:07:31.218Z","avatar_url":"https://github.com/ajaysinghj8.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ओषम् (Osham)\n\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/ajaysinghj8/osham.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/ajaysinghj8/osham/alerts/)\n[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/ajaysinghj8/osham.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/ajaysinghj8/osham/context:javascript)\n\nA Configurable Proxy Cache Server.\n\n```\nnpx osham\n```\n\n```\n npm i -g osham\n```\n\n```\n npm i osham\n```\n\n## What is ओषम् (Osham) ?\n\n**Osham** is a cache service for APIs.\n\nThe idea behind Osham is to support higher concurrent requests with fewer resources and fast response time. \n\nIn a public facing API/frontend, most of the request remains the same and so the response is also the same. To avoid rendering the same request from the backend and to speed up the response time we should use **CACHE**.\n\nThe cache can solve many problems and it uses fewer backend resources to provide a good response time.\n\n**But that's not it.**\n\nIn a real-world scenario, what happens when your backend is requested with hundreds of concurrent requests for the first time.\nIn all those concurrent requests, there will be cache miss and will cause a [thundering herd](https://en.wikipedia.org/wiki/Thundering_herd_problem) problem.\n\nAll of these problems and many more can be resolved by using Osham in your architecture.\n\n## Setup and Configure\n\n- Create a folder.\n  ```sh\n  mkdir cache\n  ```\n\n* Move in this newly created folder\n  ```sh\n  cd cache\n  ```\n\n- Install osham using\n\n  ```sh\n  npm install osham\n  ```\n\n  OR\n\n  ```sh\n  npm install osham -g\n  ```\n\n- Create a .env file.\n\n  ```sh\n  touch .env\n  ```\n\n- Configure and place following in the .env file.\n\n  ```\n  # Port number on the cache server will listen to incoming requests\n  PORT=26192\n  # Redis host name\n  REDIS_HOST=localhost\n  # Redis port number\n  REDIS_PORT=6379\n  # HTTPS Options\n  SECURE=false\n  SSL_KEY=\n  SSL_CERT=\n  # Timeout for cache service. Default is 5000 ms\n  TIMEOUT=7000\n  ```\n\n- Now, just need to create a cache-config.yml file. To get started copy file from [here](https://raw.githubusercontent.com/ajaysinghj8/osham/master/cache-config.example.yml).\n\n- Run osham as\n  If you have installed it using -g flag, you will be able to run it directly from cmd.\n\n  ```sh\n  osham\n  ```\n\n  Or\n\n  ```sh\n  ./node_module/.bin/osham\n  ```\n\n  Or using package.json\n  add into scripts of package.json as\n  \"start\": \"osham\"\n\n  ```\n  npm start\n  ```\n\n- Open http://localhost:26192/api/v1/employees in the browser.\n  Cache Server will hit the http://dummy.restapiexample.com/api/v1/employees .\n  It will cache the result for the next 5 minutes as per over about cache configuration.\n\n## Cache Options\n\n- **expose** The proxy path which will expose from osham.\n\n- **target** The actual server HOST name (with path).\n- **changeOrigin:** The actual request's HOST name will be passed to backend.\n- **followRedirects** The HTTP/HTTPS agent will be changes to follow redirects if server has internal redirection enabled.\n- **timeout** Default 5000 miliseconds.\n\n## Use Cases\n\nYou are a frontend developer and you don't want to set up backend on your machine, but want a faster development experience.\n\nTo reduce TTFB on google page insights in the production environment.\n\nTo support a large number of requests with fewer resources.\n\nCentralized many servers end-points to one.\n\n## Limitations\n\n1. It only supports anonymous requests.\n2. It will only cache GET requests.\n3. In Node Cluster, Requests will be pooled and served from the single response of backend per cache thread.\n\n## Architecture\n\n![Osham Archtecture](https://raw.githubusercontent.com/ajaysinghj8/osham/master/public/Arch.svg?sanitize=true\u0026raw=true)\n\n####\n\n![Osham Auth Arch](https://raw.githubusercontent.com/ajaysinghj8/osham/master/public/SimpleArch.svg?sanitize=true\u0026raw=true)\n\n#### More Optimized Osham\n\n![Osham master slave](https://raw.githubusercontent.com/ajaysinghj8/osham/master/public/MasterSlaveOsham.svg?sanitize=true\u0026raw=true)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajaysinghj8%2Fosham","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajaysinghj8%2Fosham","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajaysinghj8%2Fosham/lists"}