Cache the entire homepage for 5 minutes.
This means that comments and blog posts will take at most 5 minutes to show up on /.
This commit is contained in:
@@ -87,6 +87,9 @@ class CloudExtension(PillarExtension):
|
|||||||
|
|
||||||
signal_user_changed_role.connect(self._user_changed_role)
|
signal_user_changed_role.connect(self._user_changed_role)
|
||||||
|
|
||||||
|
from . import routes
|
||||||
|
routes.setup_app(app)
|
||||||
|
|
||||||
def _user_changed_role(self, sender, user: dict):
|
def _user_changed_role(self, sender, user: dict):
|
||||||
from pillar.api import service
|
from pillar.api import service
|
||||||
|
|
||||||
|
@@ -28,6 +28,10 @@ def homepage():
|
|||||||
if current_user.is_anonymous:
|
if current_user.is_anonymous:
|
||||||
return redirect(url_for('cloud.welcome'))
|
return redirect(url_for('cloud.welcome'))
|
||||||
|
|
||||||
|
return _render_homepage()
|
||||||
|
|
||||||
|
|
||||||
|
def _render_homepage():
|
||||||
# Get latest blog posts
|
# Get latest blog posts
|
||||||
api = system_util.pillar_api()
|
api = system_util.pillar_api()
|
||||||
latest_posts = Node.all({
|
latest_posts = Node.all({
|
||||||
@@ -319,3 +323,10 @@ def billing():
|
|||||||
return render_template(
|
return render_template(
|
||||||
'users/settings/billing.html',
|
'users/settings/billing.html',
|
||||||
store_user=store_user, groups=groups, title='billing')
|
store_user=store_user, groups=groups, title='billing')
|
||||||
|
|
||||||
|
|
||||||
|
def setup_app(app):
|
||||||
|
global _render_homepage
|
||||||
|
|
||||||
|
cache = app.cache.cached(300)
|
||||||
|
_render_homepage = cache(_render_homepage)
|
||||||
|
Reference in New Issue
Block a user