Ask Your Question
1

How come the cache middlewares are commented out?

asked 2013-06-08 12:47:14 -0500

kate_r gravatar image

Hi

How come UpdateCacheMiddleware and FetchFromCacheMiddleware are commented out in settings.py?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-06-08 13:13:27 -0500

Evgeny gravatar image

updated 2013-06-08 13:19:58 -0500

The reason for that is that CacheMiddleware will indiscriminately cache everything and make the site useless - for example - you won't see any updates until the cached version expires or will not see them on time.

You might experiment with caching only anonymous requests with the middleware but personally I don't like showing stale data, especially on small sites (the absolute majority of sites) where caching is almost irrelevant.

IMO, many beginner site admins assume strange ideas about "scaling" and caching. If you look at your visitor log and find that you have less than a few visits per minute - I recommend to forget about caching as long as pages are served under 1s and generated in a couple of hundred milliseconds, because solving caching invalidation correctly is not easy.

Many "large sites" (e.g. those deployed by large companies) are actually small. Instead of making assumptions - look at the actual metrics.

Once you start getting close to a dozen visits per minute - start working improving the caching. Above one visit per second proper caching is a must have.

Askbot does some caching - for example rendered fragments on the main page are cached and invalidated when necessary, b/c that page is full of detail and caching makes noticeable difference.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-06-08 12:47:14 -0500

Seen: 38 times

Last updated: Jun 08 '13