Hacker News new | past | comments | ask | show | jobs | submit login
Generate Static html cache files automatically in django (superjared.com)
11 points by nikolaj on Jan 7, 2008 | hide | past | web | favorite | 9 comments

Is this seriously the first implementation of this in Django?

I seriously hate gloating, but Rails' page caching has been around for two years. I must be mistaken.

edit: After browsing the Django documentation, it appears that I'm right. While you can store the output of a view in the filesystem (or memcached, or whatever), cached hits still need to go through the framework to get dispatched. This appears to be the first way to skip the framework (aside from Squid or similar), which is what Rails' page caching does.

Page caching creates the cached page on the first request, and dishes out the cached output until it is swept (after a new create/update/delete). This seems like the "no duh" approach. The Django "standard" way of setting a timed expiration seems silly and inflexible.

the difference here is that the html files are served by nginx, before django is event touched. Removing Django from the equation (and fastcgi or modpython or whatever nginx is proxying too) is where the speedup comes from. This isn't "caching" as much as it is fairly smoothly making certain areas of the site static html.

Yes, that's exactly my point. Is this the first approach that does this within the Django framework?

That is exactly how page caching in Rails works, and has been implemented for two years. It seems like Django's idea of "page caching" is equivalent to Rails' "action caching".

i see your point. i would assume someone else has done this before in django, but regardless, i thought it was interesting as i haven't seen something like this as easily accessible for us django people.

There are a few different levels of caching within Django. You might notice his graph has 'Django caching' in it.

It allows about 10x more requests.

His route seems to add another 10x worth of performance or something.

As to caching pages, timeouts, it is completely possible to cache things as they are created and make use of them. The timeout method is just the first, simplest way of caching saying (cache this one page for a minute, so when it gets YC'd, it only recalculates the page every minute)

Generating is never the hard part, it's keeping the cache current, pruning it when it gets too big, etc. that's hard. (Ok, I didn't read the article, yet.)

Hopefully what I created is elegant enough for people to want to use.

yeah it seems simple, that's good. And bypasses the framework, that's very good.

woot, i got news'd

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact