bionara
bionara

Reputation: 268

apostrophe cms template caching

Is it possible to create template-level caching in apostrophe CMS? Perhaps something similar to how you do in Django:

{% cache key-name variable %} cached block {% endcache %}

I had a look at the docs but couldn't see anything specific (the project name 'apostrophe' makes google searches very difficult FYI!).

Upvotes: 0

Views: 246

Answers (1)

Tom Boutell
Tom Boutell

Reputation: 7572

I am the lead architect of Apostrophe at P'unk Avenue.

Apostrophe doesn't currently have a baked-in caching mechanism of the kind you're asking about. Also, caching would not be done at the template block level because it would be an asynchronous operation, and Apostrophe's templates are rendered in a single synchronous call after all of the data has already been "mustered" and added to req.data, which exposes it as data inside the template.

Almost all of the time required to complete a request is taken up in the asynchronous code that runs prior to the start of template rendering. Since all the model-level work has already happened there is very little left to do other than move some strings around.

However, the express-cache-on-demand module is compatible with Apostrophe and can be used to cache pages on the site at precisely the time you need it — when multiple users request it at once — without any perceptibly outdated content and with no impact on logged-in users.

Upvotes: 2

Related Questions