{"id":20270643,"url":"https://github.com/sararasoulian/server-side-caching","last_synced_at":"2025-09-22T13:30:34.929Z","repository":{"id":247461313,"uuid":"824903171","full_name":"SaraRasoulian/Server-Side-Caching","owner":"SaraRasoulian","description":"✔️ A Practical Guide to Server-Side Caching in .NET","archived":false,"fork":false,"pushed_at":"2024-07-08T18:48:21.000Z","size":37,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-14T12:51:17.385Z","etag":null,"topics":["caching","dot-net-core","server-side-caching"],"latest_commit_sha":null,"homepage":"","language":"C#","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/SaraRasoulian.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2024-07-06T08:56:45.000Z","updated_at":"2024-08-14T09:09:18.000Z","dependencies_parsed_at":"2024-07-08T23:28:14.002Z","dependency_job_id":"6b8ad628-6f17-4031-b5b9-bb9581129b37","html_url":"https://github.com/SaraRasoulian/Server-Side-Caching","commit_stats":null,"previous_names":["sararasoulian/server-side-caching"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaraRasoulian%2FServer-Side-Caching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaraRasoulian%2FServer-Side-Caching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaraRasoulian%2FServer-Side-Caching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaraRasoulian%2FServer-Side-Caching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SaraRasoulian","download_url":"https://codeload.github.com/SaraRasoulian/Server-Side-Caching/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233851062,"owners_count":18740154,"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":["caching","dot-net-core","server-side-caching"],"created_at":"2024-11-14T12:32:13.994Z","updated_at":"2025-09-22T13:30:34.848Z","avatar_url":"https://github.com/SaraRasoulian.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Caching\n\nCaching means storing frequently used data in a temporary storage. Its main purpose is to speed up data delivery to users by avoiding repeated fetching from the original source.\n\nCaching reduces the time and resources needed to fetch data, making systems faster and improving user experience.\n\n## Server-side Caching in .NET\n\nThere are different ways to implement server-side caching in a .NET project. 3 commonly used techniques include:\n\n### 1. Response Caching\n\nResponse caching is specific to web applications. It means caching the entire HTTP response generated by an action method.\n\n.NET Core provides `[ResponseCache]` attribute to enable response caching for an action method.\n\nResponseCache attribute has several properties, including `NoStore`, `Duration` and `Location`.\n\nYou can also add global response caching using caching middleware in Program.cs file.\n\n### 2. In-Memory Caching\n\nIn this technique, the application stores temporary data in the main memory (RAM). It's lightweight and suitable when caching is needed within a single instance of an application.\n\n.NET Core provides `IMemoryCache` interface for managing in-memory caching. It's useful for caching small amounts of data.\n\n### 3. Distributed Caching\n\nDistributed caching involves using a shared cache across multiple instances of an application. This avoids the performance bottlenecks of having a large cache on a single server. Data consistency is maintained across servers, even if one server restarts.\n\nDistributed caching is suitable for applications with microservices architecture.\n\nIn .NET Core, popular options for distributed caching include:\n\n- Redis Cache\n- SQL Server Cache\n- NCache\n  \nIn this repository I implemented `Redis Cache` useing `StackExchange.Redis` NuGet package.\n\n\n#### Run Redis with Docker\n\nMake sure [Docker](https://docs.docker.com/get-docker/) is installed on your machine.\n\nOpen a terminal window and execute the following command to run Redis in a Docker container:\n\n```\ndocker run --name my-redis -p 6379:6379 -d redis:latest\n```\n\n\n\n---\nThese caching techniques help optimize application performance, reduce latency, and enhance user experience by delivering data faster and more efficiently.\n\nYou can see the implementation of these 3 caching techniques in the sample app in this repository.\n\n\nFeel free to create an issue or submit a pull request.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsararasoulian%2Fserver-side-caching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsararasoulian%2Fserver-side-caching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsararasoulian%2Fserver-side-caching/lists"}