mozilla/kuma — pull request #1687 by lmorchard (2013-11-21 20:06:05+00:00)
Title: bug 773522: Support expiration date or max-age for rendered document content

This PR implements an auto-re-render feature for documents. Basically, it does the equivalent of shift-refresh based on a per-document max-age (in seconds) value.

To fully work on production, this requires [bug 936626](https://bugzilla.mozilla.org/show_bug.cgi?id=936626) to be resolved. That is a request to enable [celery beat](http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html) on production.

To spot check on a local VM, there are two main avenues:

* `./manage render_stale_documents` - to manually kick off a round of rendering stale docs

* Add a new entry for `rebuild_stale` in [your djcelery periodic tasks admin page](https://developer-local.allizom.org/admin/djcelery/periodictask/). This is what we'll eventually do on production.

To ensure that celery beat is running on your local VM, ensure that `celeryd` is running with a command like so:

./manage.py celeryd --events --beat --autoreload

I added this command to `go-tmux.sh`, so it should start that way when you have a fresh tmux session.

When editing documents, you should see a new "Rendering max age" field under "Edit title and properties". You can put a number of seconds into this field - eg. 3600 for an hour, 600 for 10 min - and then you should start to see this document get re-rendered periodically based on that value.

Some ways to verify that rendering is happening:

* Check the `rendering` column in the Documents list under admin - it should update periodically.

* Check the `render_expires` column in the Documents list - it should update with a scheduled time for the next re-render.