mozilla/kitsune — pull request #1915 by rlr (2014-04-21 14:36:51+00:00)
Title: [bug 997781] Implement html caching for article page.

I think I've covered all the issues we raised in pull # 1874.

* How long does this cache last?

It will be the default from our cache settings (600 seconds in prod). We might want to override that and make it longer if this works well for a while, since we have cache invalidation

* Will this screw with voting? Will it sometimes cache a not-yet-voted page, and let anonymous users to vote a lot? Will it sometimes cache a already-voted page, and then more people can vote?

My solution to this is always show the voting for to unauth'd users. If they already voted, they will get a message about it when they try to vote again but the vote won't count.

* Most of what we do in that view isn't user specific (if any of it is at all). Could we cache the part of the page that doesn't change by user, and cache it all the time instead of caching the entire page? That might be a bigger change.

We could possibly look into more granular caching to cover auth'd users as well. My thinking here is that 99% (just guessing) of our traffic to articles will be unauth'd.

* Can we clear this cache when a document is updated? Do we want to?

DONE. I'm clearing the cache on `Document.save()`

* What do we do with query parameters? I know there is one for redirect pages (?redirect=no) that causes the page not to redirect. We need to skip cache in that case. Are there others?

redirect=no seems like the only special case that we need to handle. I skipped caching for it.

* Mobile vs Desktop templates? We need to cache them separately

Cache key depends on mobile vs not

I think that's it.

* Run the tests
* Play with the site without logging in. Vote. Make sure you can't vote again.

r?