12

I've always been impressed with StackOverflow's cache: it seems to strike a perfect balance between snappiness and sensibility.

Which of the half-dozen* cache invalidation strategies promoted by Microsoft does StackOverflow use? I personally would love to hear a 2-3 sentence summary from a member of the team, and I imagine it would be instructive to a lot of people building sites on the MSFT stack.

*Okay, maybe I exaggerate.

1

2 Answers 2

12
+50

One thing we do

  • Key: the hash of the SQL, combined with a string name
  • Value: the List<int> of ID numbers returned by the search

There's your key-value pair, and that is placed in HttpRuntime.Cache

Views take those list of IDs and hydrate the rest of the row / table values depending on what page they are on, etc.

We do both sliding cache (re-validated every time it is used) or fixed time expiration, depending on what is needed.

3
  • 1
    I thought you were using LINQ... are you getting the generated SQL somehow?
    – WildJoe
    Jul 30, 2009 at 7:26
  • So, no explicit invalidation? Just expiration? I thought for sure the site used some kind of invalidation, but I guess I've just gotten lucky. Anyways, many thanks for the reply.
    – Portman
    Aug 6, 2009 at 3:35
  • @WildJoe, you can get the SQL from your DataContext. msdn.microsoft.com/en-us/library/…
    – Portman
    Aug 6, 2009 at 3:36
0

I would assume it uses one of the cache validation strategies that the MVC framework uses. Although this site was built when the MVC was in beta, so they may have their own solution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .