Optimal ASP.Net cache duration for a large site?
- by HeroicLife
I've read lots of material on how to do ASP.Net caching but little on the optimal duration that pages should be cached for.
Let's say that I have a popular site with 50,000 pages. The content does not change frequently, so I could cache pages for up to an hour if I wanted. The server has 16 GB of RAM, but database connections are limited.
How long should pages be cached for?
My thinking is that if I set the cache duration too high (let's say 60 minutes), I will fill up memory with a fraction of the total content, which will continually be shuffled in and out of memory.
Furthermore, let's say that 10% of the pages are responsible for 90% of traffic. If the popular pages are hit every second, and the unpopular ones every hour, then a 60 second cache would only keep the load-intensive content cached without sacrificing freshness.
Should numerous but rarely-accessed content be cached at all?