He-Man: There can only be ONE master of the universe! The “Keep someone you don’t like in your phone contacts” Pattern
Aug 27

Caching Pages vs. Caching Data

Caching, Tech Add comments

I was on a new Web 2.0 application last nite. The Ajax was flowing nicely through this app, and it was sure pretty.

But then I started to notice some weird behaviour. If I added something it showed up fine on one page, but didn’t show up on another. As I navigated around this world I kept seeing inconsistencies from area to area.

I see this from time to time, and normally it smells like aggressive page caching.

I have nothing against caching at the page level. It makes a LOT of sense for many things, as the closer you get to the user, the less work you are repeating.

However, you always pay a price in this balanced world of performance and scalability. In this case, there is a lot more to keep in sync, and a lot of people ignore that side of the equation.

This is why I really like to have a caching layer for my applications which are further towards the DB than the web page itself. This cache does the hard work of keeping all of the info that I need in sync, but when it does change, the dynamic web pages automatically get that update.

This means that you get a nice balance of all worlds:

  • Data is cached closer to the user, yet not too far from the DB
  • Access times to this data cache are almost in-memory, and very fast
  • You have consistent data showing up on all of your pages

As always, this will depend on what you are doing, and it is a tricky balancing act…. but let’s try to not just turn on page caching and walk around, expecting everything to Just Work ™.

2 Responses to “Caching Pages vs. Caching Data”

  1. cacheman Says:

    I think part of the issue is that caching know comes for “free” with many applicances like the netscaler. Caching at the data layer has to actually be thought about.

  2. Dion Says:

    It is great to be able to get these things for *free* but in my experience nothing is truly for free.

    Like in this case, where the caching isn’t setup correctly wrt invalidation, and different pages have different data which is frustrating for the user.

    As soon as you go deep you really NEED to think about your caching architecture.


Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: Type in the word 'ajax'