0

I am using Django + memcached and have a (hopefully) simple question.

My database is updated once a day. My pages are set to time out after 24 hours.

Is there a way to generate all the pages of the site into the cache once each day, just after the database is updated, in advance of any users coming to them?

I'd like the first user of the day to see the fast-loading cached version, not the slow-loading non-cached version.

I guess I could do this by scraping the site, but is there a neater way?

4

1 回答 1

0

我认为这将取决于您如何设置 urls.py。

如果您的网址都是

  • A.) 直接从 urls.py

或者

  • B.) 根据您的数据库可预测

如果是这样,您也许可以使用 django_extensions show_urls

通过执行 python manage.py show_urls 它输出所有 url 的列表。

从那里,您可以将它们捕获在一个列表中并循环它们,同时使用 requests.get(some_url)

输出将告诉您是否需要一个变量。如果是这样,只需将其替换为正确的变量即可。

于 2013-06-14T19:26:38.493 回答