Should you use caching for speed?
Speeding up your responses is a good thing, but if you’re using caching as a bandaid for poor performance, then you’ll soon run into another issue, which is scalability.
At some point, you need to expire the cache or invalidate it due to new data. If your underlying code is slow, then everyone who makes a request that DOESN’T hit the cache is going to have a poor experience.
A typical response is “Well I’m not fussed if 1 in 100 of my customers has a poor experience”. Well, I can guarantee you that the user doesn’t feel the same way!
Another issue that occurs if your underlying code is slow is that you often require more resources to run that site, which leads to additional costs. And caching will only take you so far.
I’m not against caching, in fact, I use it all the time across several different systems, but I “try” to use it for scalability, NOT for performance.
You should always try to optimise your code to be as fast as possible on every request. So if you had no caching, then if your site got 10 users, they would all have a nice speedy experience. Once you have this, THEN you add in the caching.
The benefit of building your system this way is that if you suddenly go from 10 to 1000 users on your site, the site will scale well, and all of your users will get a great experience. You get the added benefit of your servers not blowing up (or scaling out to excess instances) trying to handle those slow non-cached requests.
Simon Holman
.NET and Azure Developer
I write about .NET, Azure, and cloud development. Follow along for tips, tutorials, and best practices.
Related Posts
Lower case URLs in ASP.NET Core
Common url casing in your urls, in my opinion, makes your site look nicer as a whole and has significant SEO benefit to help you drive trafiic to your site.
Implementing ASP.NET Core session with Redis Cache on Azure
Using Redis cache in Windows Azure to save session state for an ASP.NET Core web app is quick and easy to configure.
Using Redis Caching in your ASP.NET Core web app
Welcome back! In our previous videos, we covered the installation of Ubuntu on Windows 11 and explored how to install Redis Server on that Ubuntu instance.